cancel
Showing results for 
Search instead for 
Did you mean: 

Changing colour based on cells for ALV in Web Dynpro ABAP

Former Member
0 Kudos

Hi,

I have a requirement where I need to change the font color for some cells of ALV in Web Dynpro ABAP. I am able to change the font color for whole row or whole column but need to know how to change it based on cells.

My output should be something like the picture attached to this discussion. The coloumns/cells where I need the font colour can change for different rows, based on some internal condition.

Please let me know how to achieve this...... Thank you.

- Divya Posanpally

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Divya,

Your requirement can be achieved as below

  • Create an attribute for each column of alv i.e. COLOR_F1, COLOR_F2, COLOR_F3...... COLOR_F10 of type WDY_UIE_LIBRARY_ENUM_TYPE in the context node which holds the color value
  • Now while configuring ALV, set the field name of semantic color for each column as below

               data lv_color_fld_name type string.

               data lo_text_view type ref to cl_salv_wd_uie_text_view.

          loop at lt_columns into ls_column.

              

          concatenate 'COLOR'  ls_column-id into lv_color_fld_name separated by '_'.

              

          lo_text_view ?=  ls_column-r_column->get_cell_editor( ).    

          if lo_text_view is bound.

          lo_text_view->SET_SEMANTIC_COLOR_FIELDNAME( value = lv_color_fld_name ).

          endif.

          endloop.

  • Set the color based on the condition

         

         loop at lt_data into ls_data.

                   

                    if ..... "your condition here.

                    ls_data-color_f1 = cl_wd_text_view=>e_semantic_color-NEGATIVE.

                    ls_data-color_f2 = cl_wd_text_view=>e_semantic_color-POSITIVE.

                    elseif...... " another condition

              

                    endif.

          endloop.

Note: You can optimize the code as per your requirement

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Thank you for the quick response Rama......

The solution you provided works perfectly for my scenario....

- Divya Posanpally

Answers (1)

Answers (1)

harsha_jalakam
Active Contributor
0 Kudos

Hi,

Please check with the following link, check if can help.

Web Dynpro ABAP: Changing the color of a cell in ALV

Regards,

Harsha

Former Member
0 Kudos

Hi Harsha,

Thanks but I don't think this will work.

I checked the link but it colors the whole column. I need to color individual cells.

- Divya