The following extract can be used in ALV related program, where there is a requirement to have colored lines in the display, based on certain conditions.

Add a field to your output table which will determine row color.

data: begin of it_output occurs 0,

"your output fields here/ structure of ur table

ROWCOLOR (4) type c,

 end of it_output.

You can also define constants that can be used in the program instead of specifying the color, since the value does not change



constants:      red(4)     TYPE c VALUE 'C600',
                       green(4)   TYPE c VALUE 'C500'.



Once these declarations are done, you can go about processing through the internal table as per your business logic.



When you want to color the lines, just loop through the internal table and on the reqd. condition assign color for the row and modify the internal table.

loop at it_output.

if it_output-field1 > 5.               "YOU’RE condition here

it_output-rowcolor = red.          "assign color to row

else.

it_output-rowcolor = green.

endif.

modify it_output.                         "modify internal table

endloop.



but we still need to integrate this with the ALV display function module, this can be done by creating a structure of type slis_layout_alv.


 DATA : fs_layout type slis_layout_alv.
fs_layout-info_fieldname = 'ROWCOLOR'.



This is to be passed to the function module that displays ALV, it shows in which field the color information is.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      i_callback_program      = sy-repid

      i_callback_user_command = ''

      it_fieldcat             = it_fcat

      is_layout               = fs_layout  "give the layout structure

    TABLES

      t_outtab                = it_zsapb_ctrlview.




Serkan AKKAVAK
Computer Engineer
serkurumsal@yandex.com