The method set_color of the class CL_SALV_COLUMN_TABLE can be used to color the column of SAP ALV Display.
The color codes are much similar to old ALV Display of type CL_GUI_ALV_GRID
DATA lr_all_columns TYPE REF TO cl_salv_columns_table.
DATA lr_single_column TYPE REF TO cl_salv_column_table.
Lr_all_columns = lr_salv_table->get_columns( ).
Lr_single_column ?= lr_all_columns->get_column(‘CONTACT_NAME’).
DATA ls_color_column TYPE lvc_s_scol.
Ls_color_column-col = 7.
Ls_color_column-int = 1.
Ls_color_column-inv = 1.
Lr_single_column->set_color( value = ls_color_column ).
The column ‘Contact_name’ is colored or highlighted in orange colour.
The following table shows the other different colour codes. It is same as the old ALV Display.
Color | color_code | col | int | inv |
Green | C510 | 5 | 1 | 0 |
Red | C610 | 6 | 1 | 0 |
Orange | C711 | 7 | 1 | 1 |