這時我們可以在ALV的程式內加入以下顏色控制的欄位宣告
並在該資料項判斷後Modify這個值
最後在Layout控制加上該色彩控制..(如無設定程式會有Error)
*增加色彩欄位宣告
DATA: BEGIN OF GW_ITAB,
C1 TYPE C,
P1 TYPE P.
DATA: COLINFO TYPE SLIS_T_SPECIALCOL_ALV, "必要的宣告
END OF GW_ITAB.
DATA GT_ITAB LIKE GW_ITAB OCCURS 0 WITH HEADER LINE.
DATA: GT_COLOR TYPE SLIS_T_SPECIALCOL_ALV WITH HEADER LINE.
LOOP AT GT_ITAB
IF GT_ITAB < 0.
GT_COLOR-FIELDNAME = P1.
GT_COLOR-COLOR-COL = 6.
GT_COLOR-COLOR-INT = 0.
GT_COLOR-COLOR-INV = 1.
APPEND GT_COLOR.
CLEAR GT_COLOR.
GT_ITAB-COLINFO = GT_COLOR[].
MODIFY GT_ITAB.
ENDIF.
ENDLOOP.
*&----------------------------------------------------------------*
*& Form LAYOUT_INIT
*&----------------------------------------------------------------*
FORM LAYOUT_INIT USING P_L_LAYOUT TYPE SLIS_LAYOUT_ALV.
P_L_LAYOUT-COLTAB_FIELDNAME = 'COLINFO'.
ENDFORM. " LAYOUT_INIT
沒有留言:
張貼留言