Coloring Cells 
You can color cells in the grid control different colors and in this way highlight data in the list. With this process it is also possible to color whole rows however this is more time-consuming than described under Coloring Rows.
Note
The process D&D Behavior for Special Rows/Cells is analog with regard to the method for selecting cells.
Define the Layout Structure of type LVC_S_LAYO.
Add a color table of type LVC_T_SCOL to your output table, as shown in the example below:
Syntax
DATA: BEGIN OF GT_OUTTAB OCCURS 0. INCLUDE STRUCTURE <DDIC-Struktur>. DATA: CT TYPE LVC_T_SCOL. "Table for colors DATA: END OF GT_OUTTAB.
Select your data and copy it into the output table.
Read one row of the output table at a time in a loop. A row of the color table has three fields. If the NOKEYCOL field is set you can change the color or key fields. Complete the remaining fields as follows:
If you want to color the entire row, assign the relevant values to the fields of the structure COLOR. Field fname does not receive a value in this case.
If you only want to color specific columns, you must append one row for each column to the color table. Assign the fname field the name of the required column and the fields of the COLOR structure the relevant values.
Note
You can find the meaning of color settings in the input help for the format command. The class CL_GUI_RESOURCES contains constant attributes for the fields INT and INV of the structure COLOR.
Assign the name of the internal table to the field CTAB_FNAME of the layout structure (which, in our case, is 'CT', see step 2).
Pass the layout structure and the output table with method et_table_for_first_display.
Note
If you do not want to color cells for the first display, execute step 4 later and refresh the output table with the method refresh_table_display.
To make colored identifiers of ALV elements accessible to visually-impaired users it is necessary to maintain a tool tip for the color.
For this you have to maintain some fields in the table it_except_qinfo for the interface CL_GUI_ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY:
TYPE |
Mandatory |
4 (= Color) |
FIELDNAME |
optional |
Only has to be completed if the meaning of the color in relation to the related values for VALUE and TEXT is only valid in a special column of the ALV. |
VALUE |
Mandatory |
Color of elements. |
TEXT |
Mandatory |
Tooltip text. |
Note
Table it_except_qinfo is of type slist_t_qinfo_alv.