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

ALV Tree - Color Specific Column based on value in that cell?

Former Member
0 Kudos

Hi Forums,

I have searched the forum and I am unable to find the answer to my question.

I am using an ALV tree and I would like to color a cell RED is the value in the cell is negative.

I have set my field catalog to many different emphasize numbers and no luck either?


  CLEAR ls_fieldcatalog.
  ls_fieldcatalog-fieldname  = 'ORG_TXT'.
  ls_fieldcatalog-coltext    = text-d02.
  ls_fieldcatalog-scrtext_m  = text-d02.
  ls_fieldcatalog-col_pos    = 2.
  ls_fieldcatalog-outputlen  = '30'.
  ls_fieldcatalog-no_out     = 'X'.
  ls_fieldcatalog-emphasize  = 5.
  APPEND ls_fieldcatalog TO et_fieldcatalog.

I am using

    gr_alv_tree_control  TYPE REF TO cl_gui_alv_tree 

as my class to display my tree and I have found no methods that would set the color in there either?

What else could be checked?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Check this links and also the wiki link and see if it would be helpful for you

http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP-ChangingCellcharacteristicsinALV+(OOPS)

5 REPLIES 5

Former Member
0 Kudos

Check this links and also the wiki link and see if it would be helpful for you

http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP-ChangingCellcharacteristicsinALV+(OOPS)

0 Kudos

Thanks Kris, that is help for a regular ALV but it does not solve the issue when using a TREE ALV

0 Kudos

Sorry I didn't notice it was ALV tree... There is one thread, where a OP figured it out but unfortunately did not share his results;

http://help.sap.com/saphelp_nw04/helpdata/en/34/e7eb40c4f8712ae10000000a155106/frameset.htm

It looks like you can highlight individual rows, but there does not seem to be a option to highlight a particular cell (as far as I can see)

0 Kudos

To those interested, i was able to color the TEXT of a First coloumn of the TREE. Using this code:

That said it will not work without BOTH


       ls_layout_item-fieldname = gr_alv_tree_control->c_hierarchy_column_name.
      ls_layout_item-style   =
                           cl_gui_column_tree=>style_intensifd_critical.



    IF ls_vip_display-vip_diff_tot > 0.
       ls_layout_item-fieldname = gr_alv_tree_control->c_hierarchy_column_name.
      ls_layout_item-style   =
                           cl_gui_column_tree=>style_intensifd_critical.
    ENDIF.
    IF ls_vip_display-vip_diff > 0.
      ls_layout_item-style   =
                           cl_gui_column_tree=>style_intensifd_critical.
    ENDIF.
    ls_layout_item-t_image = '@GZ@'.
    ls_layout_item-style   =
                        cl_gui_column_tree=>style_intensifd_critical.
    APPEND ls_layout_item TO lt_layout_item.

*   add leaf nodes
    CALL METHOD gr_alv_tree_control->add_node
      EXPORTING
        i_relat_node_key     = lv_parent_id
        i_relationship       = cl_gui_column_tree=>relat_last_child
        i_node_text          = lv_node_text
        is_outtab_line       = ls_vip_display
        it_item_layout       = lt_layout_item
        is_node_layout       = ls_node_layout
      IMPORTING
        e_new_node_key       = lv_new_key
      EXCEPTIONS
        relat_node_not_found = 1
        node_not_found       = 2
        OTHERS               = 3.

Anybody else who can shed some light to why both are needed OR possibly how I can change the position of the colored text to a different cell?

Edited by: Keith Warnock on Feb 9, 2011 6:48 PM

Former Member
0 Kudos

see my last post