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.
Showing results for 
Search instead for 
Did you mean: 

SET Color to the fixed columns - CL_SALV_TABLE

Former Member
0 Kudos

Hi All,

I have used the following code to lock the columns

lr_columns->set_key_fixation( ).

** lock the Plant column
  TRY .
      lr_column ?= lr_columns->get_column( 'WERKS' ).
      lr_column->set_color( color ).
    CATCH cx_salv_not_found.
  IF lr_column IS BOUND.
    lr_column->set_key( ).
    lr_column->set_key_presence_required( ).

But It displays only default color. I want fixed columns background color should be Green.

I have used SET_COLOR, but it not worked.




Former Member
0 Kudos

search the forums, including articles and Wikis...I know N. Patel has done some things on SALV color and there are other posts, as I recall. I add a color column to my SALVs....

0 Kudos

Thanks for your quick reply.

I know how to change the color of columns.

My requirement is to fix the columns and change the color of the fixed columns only.

In the above case my code fails to change the color of the fixed columns.

It shows only the default color for the fixed columns.

I hope you can understand my requirement.

0 Kudos


Maybe just try to switch the sequence:

set column as a key

set color for a column.

I haven't try this before, so please give some feedback, how have you solved this problem.

Anyway, maybe it is another way to try?



0 Kudos

data: color type lvc_s_colo.

gr_column ?= gr_columns->get_column( 'FIELDNAME' ).

color-col = '6'.

color-int = '1'.

color-inv = '0'.

gr_column->set_color( color ).

Just try this,Hope it helps u.

Former Member
0 Kudos

I am able to do this in SALV....hope this is helpful to you... adjust your color no. I don't remember what green is 3 is yellow?

Consider code:

        gs_color-fname     = 'CLAIM'.  "GS_COLOR typed :lvc_s_scol
          gs_color-color-col = 3.
          gs_color-color-int = 1.
          gs_color-color-inv = 0.
          append gs_color to gt_color. "GT_COLOR type lvc_t_scol

If you have additional key fields....change FNAME and append to gt_color again!

loop at gt_pays assigning <lfs_x>.
    if <lfs_x> is assigned.
       <lfs_x>-color = gt_color.  "color is TYPE lvc_t_scol

In my column titles and attributes CLAIM is column

* get the column named in col_name variable.
      gr_column ?= gr_columns->get_column( lv_col_name ).

    catch cx_salv_not_found into gr_error.
      concatenate 'Column name' lv_col_name 'not found.'
        into lv_msg separated by space.
      if lv_col_name ne 'COLOR'.
        message lv_msg type 'I' display like 'E'.

. . . 

case gv_col_no.
    when 1 or 2.
      gr_column->set_key( abap_true  ).   "Key Field
      gr_column->set_f4(  abap_false ).   "no dropdown
* Column 1 is hotspot for single click ICL_CLAIM_CENTER FM call
      if gv_col_no eq 1.
        call method gr_column->set_cell_type
            value = if_salv_c_cell_type=>hotspot.           "Type 5
    when 19 or 20. "19 is not displayed and 20 is column named COLOR
      gr_column->set_technical( if_salv_c_bool_sap=>true ).
      gr_column->set_visible( if_salv_c_bool_sap=>false ).
      if gv_col_no eq 20.
            gr_columns->set_color_column( 'COLOR' ).  "row color control column
          catch cx_salv_data_error.                     "#EC NO_HANDLER

Edited by: BreakPoint on Feb 10, 2011 4:45 PM - multiple key fields can be handled also.

Active Contributor


you can override the automatic setting of key column colors using the field NOKEYCOL of the structure LVC_S_SCOL. Consider this coding:

       gs_color-fname     = 'CLAIM'.  "GS_COLOR typed :lvc_s_scol

          gs_color-color-col = 3.

          gs_color-color-int = 1.

          gs_color-color-inv = 0.

          gs_color-nokeycol = abap_true. " <----- Override key colors!

          append gs_color to gt_color. "GT_COLOR type lvc_t_scol

you can also leave the FNAME blank, if you do not have column specific colors, but only line specific ones.

Best regards