SAP: Changing ALV Row Color

Changing the color of an ALV row is very simple. First you have to add a field on your internal table that will holds the color attribute (Refer to the sample code below).

TYPES: BEGIN OF t_rowcolor,
column1 TYPE string,
column2 TYPE string,
column3 TYPE string,
rowcolor(4) TYPE c,
END OF t_rowcolor.

DATA:  it_rowcolor TYPE STANDARD TABLE OF t_rowcolor,
wa_rowcolor TYPE t_rowcolor.

Next step is to Set the layout field for color attributes. In our case, that field is “rowcolor” (Refer to the sample code below).

DATA: gd_layout TYPE slis_layout_alv.

gd_layout-info_fieldname = ‘ROWCOLOR’.

Lastly, you have to populate the rowcolor field with the color attributes of your choice. You can do this when you loop at your internal table into your work area table (Refer to the sample code below).

LOOP AT it_row INTO wa_row.
wa_row-rowcolor = ‘C100′
MODIFY it_row FROM wa_row.
ENDLOOP.

In the code above, ‘C100′ is the color attribute. For the complete list of different color attributes, please refer to the figure below.

ALV color attributes

0 Responses to “SAP: Changing ALV Row Color”


  1. No Comments

Leave a Reply