Continue this topic.
This article explains how to set the color of cells that meet the conditions. For example, in a report, set the cells with scores less than 60 to red. This function is common!
1. First, remember to add a column color when defining the internal mark:
....
CELLCOLOR TYPE LVC_T_SCOL,
...
2. When modifying the internal table, add the following content to the column:
DATA: W_CELLCOLOR TYPE LVC_S_SCOL.
IF IT_SFLIGHT-PRICE <= 1000. "Red less than 1000
CLEAR IT_SFLIGHT-COLOR.
W_CELLCOLOR-FNAME = 'price'. "Color Bar
W_CELLCOLOR-COLOR-COL = '6'. "Red
W_CELLCOLOR-COLOR-INT = '1'. "color deepening 0 means not deepening
APPEND W_CELLCOLOR TO IT_SFLIGHT-CELLCOLOR.
ENDIF.
3. When setting ALV format:
*&---------------------------------------------------------------------*
* & FORM PREPARE_LAYOUT
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> PS_LAYOUT TEXT
*----------------------------------------------------------------------*
FORM PREPARE_LAYOUT CHANGING PS_LAYOUT TYPE LVC_S_LAYO.
PS_LAYOUT-ZEBRA = 'x '.
PS_LAYOUT-GRID_TITLE = TITLE.
PS_LAYOUT-SMALLTITLE = 'x '.
PS_LAYOUT-SEL_MODE = 'A '.
PS_LAYOUT-INFO_FNAME = 'color '.
PS_LAYOUT-CTAB_FNAME = 'cellcolor'. "Must be capitalized
PS_LAYOUT-CWIDTH_OPT = 'x '.
PS_LAYOUT-DETAILINIT = 'x '.
ENDFORM. "PREPARE_LAYOUT
The effect is as follows: