1 在内表中加入颜色字段
.............................
color(4) type c,
................................
2 在内表添加记录是通过条件设置颜色字段值
wa_customerinfo-color = 'C110'.
3 设置颜色控制内表 slis_layout_alv 的颜色字段为内表增加的颜色字段
data g_slis_layo type slis_layout_alv. "定义Grid输出颜色控制内表
g_slis_layo-info_fieldname = 'COLOR'.
4 输出记录
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
is_layout = g_slis_layo
it_fieldcat = g_field[]
it_sort = g_sort[]
it_events = event_top_of_page[]
tables
t_outtab = i_customerinfo.
以下为显示表头的代码
data event_top_of_page type slis_alv_event occurs 0 with header line.
perform event_top_of_page tables event_top_of_page.
form event_top_of_page tables rt_event type slis_t_event.
refresh rt_event.
clear rt_event.
rt_event-name = slis_ev_top_of_page.
rt_event-form = 'WRITE_TOP_OF_PAGE'.
append rt_event.
endform. "event_top_of_page
form write_top_of_page.
data: hline type slis_listheader,
text(60) type c,
text10(10) type c,
text5(5) type c,
percent type p decimals 2.
refresh head.
clear head.
clear: hline, text.
hline-typ = 'S'.
write: '时间:', g_curdate to text.
hline-info = text.
append hline to head.
write: '客户状态:绿色-老呆死客户,红色-新呆死客户,兰色-超信用额度客户'
to text.
hline-info = text.
write: g_countkunnr to text5.
append hline to head.
concatenate '往来单位:' text5 '个.' into text.
hline-info = text.
append hline to head.
write: g_oldbad_count to text5.
concatenate '老呆死帐单位:' text5 '个,占' into text.
percent = g_oldbad_count * 100 / g_countkunnr.
write: percent to text5.
concatenate text5 '%' into text+23.
write: g_newbad_count to text5.
concatenate '新呆死单位:' text5 '个,占' into text+30.
percent = g_newbad_count * 100 / g_countkunnr.
write: percent to text5.
concatenate text5 '%' into text+53.
* CONDENSE text.
hline-info = text.
append hline to head.
clear text.
percent = g_ccdebit_count / 10000.
write: percent to text10.
concatenate '应收帐款:' text10 '万元' into text.
percent = g_webtr_count / 10000.
write: percent to text10.
concatenate '认可呆死帐:' text10 '万元.' into text+30.
hline-info = text.
append hline to head.
percent = g_oldbad_money / 10000.
write: percent to text10.
concatenate '老呆死帐款:' text10 '万元,' into text.
percent = g_oldbad_money * 100 / g_ccdebit_count.
write: percent to text5.
concatenate '占' text5 '%' into text+30.
hline-info = text.
append hline to head.
percent = g_newbad_money / 10000.
write: percent to text10.
concatenate '新呆死帐款:' text10 '万元,' into text.
percent = g_newbad_money * 100 / g_ccdebit_count.
write: percent to text5.
concatenate '占' text5 '%' into text+30.
hline-info = text.
append hline to head.
write: g_over_count to text5.
concatenate '超安全额度单位:' text5 '个,' into text.
percent = g_over_count * 100 / g_countkunnr.
write: percent to text5.
concatenate '占' text5 '%' into text+24.
percent = g_over_money / 10000.
write: percent to text10.
concatenate '超安全额度:' text10 '万元.' into text+30.
hline-info = text.
append hline to head.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = head.
endform. "write_top_of_page