cancel
Showing results for 
Search instead for 
Did you mean: 

Setting individual cell colours in ALV with cell variant

Former Member
0 Kudos

Hi

I wonder if you can help me please, I am having issues implementing ALV cell changes in WDA?

I am basically trying to dynamically change the individual color of a cells (not the entire column or row) dependant on certain criteria. I have read several threads around this topic but cannot figure out how to implement this. Please see screen shot below.

Currently my code is as follows:



Please see: <a href="www.picasaweb.google.co.uk/dave.alexander69/Pictures#5244416971466907938" TARGET="test_blank">www.picasaweb.google.co.uk/dave.alexander69/Pictures#5244416971466907938</a>

data: lr_cv TYPE REF TO cl_salv_wd_cv_standard. 

loop at table 1 row data 
        loop at table columns 

          for the date columns only... 
          IF <fs_column>-id(4) = 'CELL'. 

           get and set column header dates from select option user input - done 

            loop at table 2 row data (table 2 contains date ranges for row concerned) 

              MOVE: ls_zdata-variance TO lv_variance. 
              method 1 - as in sap press WD4A -: 
              lr_cv = cl_wd_table_standard_cell=>new_table_standard_cell( 
                                                 view        = view 
                                                variant_key = lv_variance ). 


             as mentioned... 
              CREATE OBJECT lr_cv. 
              lr_cv->set_key( 'VARIANCE' ). 
              lr_cv->set_cell_design( '09' ). 
              lr_cv->set_editor( lr_input_field ). 
              lr_column->add_cell_variant( lr_cv ). 
              lr_column->set_cell_editor( lr_input_field ). 
              lr_column->set_sel_cell_variant_fieldname( 'VARIANCE' ). 

              lr_column->set_cell_design_fieldname( value = 'COLOR_CELL' ). 

              lr_field = lr_table->if_salv_wd_field_settings~get_field( <fs_column>-id ). 
              lr_field->if_salv_wd_sort~set_sort_allowed( abap_false ). 

              the only way I get cell coloring to work - but this is for entire column? 
              ls_zdata-color_cell = cl_wd_table_standard_cell=>e_cell_design-one. 

              MODIFY lt_zdata FROM ls_zdata.. 

            ENDLOOP. 

          ENDIF. 
          IF <fs_column>-id = 'COLOR_CELL'. 
            CALL METHOD lr_column->set_visible( EXPORTING value = '00' ). 
          ENDIF. 
        ENDLOOP 
      ENDLOOP.

I am in the dark regarding the use of cell variants and wonder if you can point me in a better direction.

Many thanks in advance for any help,

Dave Alexander

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thankyou for your response Abhi

lr_column->set_cell_design_fieldname( value = 'COLOR_CELL' ).

'COLOR_CELL' is a reference to an 'attribute' in the context structure which enables me to set the cell colour for a particular row. This method sets a column cell or multiple column cells with the design that is passed:

i.e. ls_zdata-color_cell = cl_wd_table_standard_cell=>e_cell_design-one.

Unfortunately I need to set colored cells at multiple points within a row in the grid - and this is whats causing me the problem. If I set the color for a row like this it is effecting all marked columns within the grid. This suggests I may or should be using a cell variant to do this.

If you or anyone can help it would be greatly appreciated.

~Cheers

Dave

abhimanyu_lagishetti7
Active Contributor
0 Kudos

is this has any significance

lr_column->set_cell_design_fieldname( value = 'COLOR_CELL' ).

Abhi