列颜色设置:
代码语言:javascript复制*------------------------定义宏--------------------*
DEFINE INIT_FIELDCAT.
CLEAR GS_FIELDCAT.
GS_FIELDCAT-FIELDNAME = &1. "字段名
GS_FIELDCAT-COLTEXT = &2. "ALV 控制: 列标题
GS_FIELDCAT-EDIT = &3." 是否可编辑
case &1.
when 'VBELN'.
gs_fieldcat-emphasize = 'C601'."颜色设置 1 字体颜色,0 背景颜色
when 'ERDAT'.
gs_fieldcat-emphasize = 'C600'.
ENDCASE.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
END-OF-DEFINITION.
行颜色设置:
FORM FRM_DEALDATA .
*设置行颜色
types:line_color(4) type c,
LOOP AT GT_DATA INTO GS_DATA.
if gs_data-ERNAM = '33440'.
gs_data-line_color = 'C600'.
ENDIF.
MODIFY GT_DATA FROM GS_DATA.
ENDLOOP.
ENDFORM.
FORM FRM_LAYOUT .
gs_layout-info_fname = 'line_color'."行颜色
ENDFORM.
单元格颜色设置:
types:FIELD_COLOR TYPE LVC_T_SCOL, "单元格颜色
FORM FRM_DEALDATA .
*设置单元格颜色
DATA:LS_SCOL TYPE LVC_S_SCOL.
LOOP AT GT_DATA INTO GS_DATA.
IF GS_DATA-ERNAM = '33440'.
LS_SCOL-FNAME = 'ERNAM'.
LS_SCOL-COLOR-COL = 6 .
LS_SCOL-COLOR-INT = 0 .
LS_SCOL-COLOR-INV = 0 .
APPEND LS_SCOL TO GS_DATA-FIELD_COLOR .
ENDIF.
MODIFY GT_DATA FROM GS_DATA.
ENDLOOP.
ENDFORM.
FORM FRM_LAYOUT .
GS_LAYOUT-CTAB_FNAME = 'field_color'."单元格颜色
ENDFORM.