Раскраска строк в ALV GRID SAP ABAP Coloring a Row

Coloring a Row
Step 1: Include a field called rowcolor in output internal table.
types : begin of ty.
include structure MARA.
Types : rowcolor(4) TYPE c,
end of ty.
data : itab type standard table of ty,"Output Internal table
wa type ty.
Step 2: Setting the layout accordingly
Data w_layout TYPE lvc_s_layo."Layout structure
* Setting layout
w_layout-info_fname = 'ROWCOLOR'."For row coloring
Step 3: Coloring the specific row * Colouring a row
CLEAR wa.
READ TABLE itab INTO wa INDEX 3.
IF sy-subrc EQ 0.
wa-rowcolor = 'C311'.
MODIFY itab FROM wa TRANSPORTING rowcolor WHERE matnr = wa-matnr.
ENDIF.
Step4: Pass the layout also in the method set_table_for_first_display
* Displaying the output
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
IS_VARIANT = w_variant
I_SAVE = 'A'
is_layout = w_layout
CHANGING
it_outtab = itab
IT_FIELDCATALOG = i_fieldcat
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Добавить комментарий