Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

using cl_salv_column_table to adjust color

former_member184386
Active Participant
0 Kudos

Hello,

Is there a way I could change the color of a cell using the class "cl_salv_column_table", I wanted to make all the cells that have let say value of 10 to be in red.

Thanks in advanced.

1 ACCEPTED SOLUTION

uwe_schieferstein
Active Contributor
0 Kudos

Hello Ricky

You should have a look at sample report SALV_DEMO_TABLE_COLUMNS:


...
*... §5.2 set the color of a complete row
*    (2) set the color information to the row in the output
*        table.
*        note: do not fill the parameter FNAME for setting the
*              color of the complete row
*              fill the parameter FNAME for setting the color
*              of a cell (Row and Column are definied)
        clear lt_color.
        clear ls_color.

        ls_color-fname     = 'PRICE'.
        ls_color-color-col = col_negative.
        ls_color-color-int = 0.
        ls_color-color-inv = 0.
        append ls_color to lt_color.

        ls_color-fname     = 'FLDATE'.
        ls_color-color-col = col_positive.
        ls_color-color-int = 0.
        ls_color-color-inv = 0.
        append ls_color to lt_color.

        <ls_outtab>-t_color = lt_color.

        clear lt_celltype.
        clear ls_celltype.

        ls_celltype-columnname = space.
        ls_celltype-value      = if_salv_c_cell_type=>text.
        append ls_celltype to lt_celltype.

        <ls_outtab>-t_celltype = lt_celltype.
    endcase.
...


...
*... §5.2 set the color of a complete row
*    (1) register the column in which the color information
*        for the row is held
  try.
      lr_columns->set_color_column( 'T_COLOR' ).
    catch cx_salv_data_error.                           "#EC NO_HANDLER
  endtry.
...

Regards

Uwe

3 REPLIES 3

Former Member
0 Kudos

See

Rob

0 Kudos

Thanks for the quick reply, but this is the other way of doing ALV output, I was expecting something about using this specific class (cl_salv_column_table).

Edited by: Ricky Orea on Sep 10, 2009 10:58 AM

uwe_schieferstein
Active Contributor
0 Kudos

Hello Ricky

You should have a look at sample report SALV_DEMO_TABLE_COLUMNS:


...
*... §5.2 set the color of a complete row
*    (2) set the color information to the row in the output
*        table.
*        note: do not fill the parameter FNAME for setting the
*              color of the complete row
*              fill the parameter FNAME for setting the color
*              of a cell (Row and Column are definied)
        clear lt_color.
        clear ls_color.

        ls_color-fname     = 'PRICE'.
        ls_color-color-col = col_negative.
        ls_color-color-int = 0.
        ls_color-color-inv = 0.
        append ls_color to lt_color.

        ls_color-fname     = 'FLDATE'.
        ls_color-color-col = col_positive.
        ls_color-color-int = 0.
        ls_color-color-inv = 0.
        append ls_color to lt_color.

        <ls_outtab>-t_color = lt_color.

        clear lt_celltype.
        clear ls_celltype.

        ls_celltype-columnname = space.
        ls_celltype-value      = if_salv_c_cell_type=>text.
        append ls_celltype to lt_celltype.

        <ls_outtab>-t_celltype = lt_celltype.
    endcase.
...


...
*... §5.2 set the color of a complete row
*    (1) register the column in which the color information
*        for the row is held
  try.
      lr_columns->set_color_column( 'T_COLOR' ).
    catch cx_salv_data_error.                           "#EC NO_HANDLER
  endtry.
...

Regards

Uwe