ALV的顏色標示
ALV的顏色標示可分為三種
1. 橫向
2. 縱向
3. 儲存格
1. 以橫向標示來說
可以在ITAB 塞一個欄位叫做COLOR_LINE
例如:
DATA: BEGIN OF ALV_LIST OCCURS 0,
…………….
COLOR_LINE(4).
END OF ALV_LIST.
然後塞資料到ITAB時決定該筆數要顯示的顏色
例如
LOOP AT ALV_LIST.
IF ALV_LIST-KWMENG > 10.
ALV_LIST -COLOR_LINE = 'C600'.
ENDIF.
接下來要設定g_layout-info_fieldname後就可以輸出的
g_layout-info_fieldname = 'COLOR_LINE'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = g_layout
2. 以縱向標示來說
要將第四個欄位改成紅色
…………..
g_fieldcat -emphasize = ‘C600’.
APPEND g_fieldcat.
3. 將儲存格改成紅色
例如:第四個欄位的第六筆區塊改成紅色
DATA ls_cellcolour TYPE lvc_s_scol.
DATA: BEGIN OF ALV_LIST OCCURS 0,
…………….
cell_colour TYPE lvc_t_scol.
END OF ALV_LIST.
LOOP AT ALV_LIST.
IF ALV_LIST-KWMENG > 10.
ls_cellcolour-color-col = '6'.
ls_cellcolour-fname = ‘KWMENG’.
ls_cellcolour-color-int = '1'.
ls_cellcolour-color-inv = '0'.
APPEND ls_cellcolour TO ALV_LIST-cell_colour.
ENDIF.
MODIFY ALV_LIST.
ENDLOOP.
然後
g_layout-coltab_fieldname = 'CELL_COLOUR'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = g_layout
留言列表