Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Setting individual cell colours in ALV with cell variant

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: www.picasaweb.google.co.uk/dave.alexander69/Pictures#5244416971466907938

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

Not what you were looking for? View more on this topic or Ask a question