Column Color: FIELDCAT achieved by emphasizing the field of the field catalog
Line Color: LAYOUT achieved by, adding a field to the display color table stored it
Cell color: achieved by LAYOUT, a table is added to the display memory color in the table (the table type: LVC_T_SCOL)
Cell color color design provided with basically the same row 1 in the table including ALV data, add a table within CellColor, for recording color codes, it is necessary to set the color of the field name structure of CellColor: FNAME ALV control: internal table field name field of cOLOR the ALV control: color code cOLOR is a structure: COL the ALV control: color; the INT the ALV control: Tempered 1 / 0 ; INV the ALV control: opposite 1 / 0 set color foreground or background NOKEYCOL ALV control: color cover code 2 the cycle table, color code set. the REPORT Z1113. the TYPES : the BEGIN . OF TYP_01, MATNR the TYPE MARA- MATNR, ERNAMTYPE MARA-ERNAM, ERSDA TYPE MARA-ERSDA, COLOR TYPE CHAR04, CELLCOLOR TYPE LVC_T_SCOL,"单元格颜色 END OF TYP_01. DATA IS_CELLCOLOR TYPE LVC_S_SCOL. DATA GT_01 TYPE STANDARD TABLE OF TYP_01 WITH HEADER LINE . DATA IT_FIELDCAT TYPE LVC_T_FCAT WITH HEADER LINE . DATA IS_LAYOUT TYPE LVC_S_LAYO. DEFINE FIELDCAT. IT_FIELDCAT-COL_POS = &1. IT_FIELDCAT-FIELDNAME = &2. IT_FIELDCAT-SCRTEXT_L = &3. APPEND IT_FIELDCAT. END-OF-DEFINITION. START-OF-SELECTION. SELECT MARA~MATNR MARA~ERNAM MARA~ERSDA FROM MARA INTO CORRESPONDING FIELDS OF TABLE GT_01. END-OF-SELECTION. FIELDCAT '1' 'MATNR' 'MATNR'. LOOP AT IT_FIELDCAT. IF IT_FIELDCAT-FIELDNAME = 'MATNR'. IT_FIELDCAT-EMPHASIZE = 'C710'. MODIFY IT_FIELDCAT. CLEAR IT_FIELDCAT. ENDIF. ENDLOOP. FIELDCAT '2' 'ERNAM' 'ERNAM'. FIELDCAT '3' 'ERSDA' 'ERSDA'. LOOP AT GT_01. IF GT_01-MATNR = '000000000000000097'. GT_01-COLOR = 'C610'. MODIFY gt_01. CLEAR GT_01. ENDIF. IF GT_01-MATNR = '000000000000000129'. GT_01-COLOR = 'C510'. MODIFY GT_01. CLEAR GT_01. ENDIF. IF = MATNR-GT_01 ' 000000000000000153 ' . IS_CELLCOLOR -FNAME = ' MATNR ' . " Material number of '153' is 'MATNR' field of the line color is yellow IS_CELLCOLOR- COLOR -COL = . 3 . IS_CELLCOLOR - COLOR -INT = . 1 . IS_CELLCOLOR - COLOR -INV = 0 . the APPEND IS_CELLCOLOR the TO GT_01- CELLCOLOR. the MODIFY GT_01. the CLEAR GT_01. ENDIF . ENDLOOP . IS_LAYOUT-CWIDTH_OPT = 'X'. IS_LAYOUT-INFO_FNAME = 'COLOR'. IS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'. "单元格颜色内表字段 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING I_CALLBACK_PROGRAM = SY-CPROG IS_LAYOUT_LVC = IS_LAYOUT IT_FIELDCAT_LVC = IT_FIELDCAT[] TABLES T_OUTTAB = GT_01[]. * EXCEPTIONS * PROGRAM_ERROR = 1 * OTHERS = 2 . IF SY-SUBRC <> 0. * Implement suitable error handling here ENDIF.
operation result: