cancel
Showing results for 
Search instead for 
Did you mean: 

setting new cell variant for an alv table column

Former Member
0 Kudos

Hi,

I want to set a new cell variant for a column. Therefore I did the following steps:

1. Create an object of CL_SALV_WD_CV_STANDARD

2. SET_KEY( 'CELLVAR1 )

3. set_cell_design([..]-goodvalue_medium )

4. SET_EDITOR( lr_alv_input_field )

After that I added the cell variant to the column by using the method "add_cell_variant".

The last step is to call method SET_SELECTED_CELL_VARIANT.

I checked my program by using get_selected_cell_variant( ) and the return string was okay.

But when the table is displayed, the new cell variant isn't working. I defined an input field as the cell editor for my new cell variant but when the table is shown, it is just text - no input possible. In addition to that the selected cell design (goodvalue_medium , step 3) isn't working. So I think the cell variant is not used.

Can you help me?

Thanks & Regards,

Hendrik

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

What you describe sounds correct. Actually I just posted a suggestion in another forum thread that uses Cell Variants in ALV:

This solution worked fine for me (as you can see in the screen shots). The only difference I can see is that I used the set_sel_cell_variant_fieldname to control dynamically which cell variant is used. Perhaps if you look over the code from my solution you might find some other minor difference that you are missing.

Former Member
0 Kudos

Hi

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

I am basically trying to dynamically change the individual color of a cell (not the entire column or row) dependant on certain criteria. I apologies but find that you are the closest resource for any potential information. Please see screen shot below.

Currently my code is as follows:



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.

As you see I am in the dark a bit regarding cell variants and wonder if you can point me in a better direction.

Many thanks for any help,

Dave Alexander

Answers (0)