This website is not affiliated with, sponsored by, or approved by SAP AG.

Icons using CL_SALV_TREE

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Icons using CL_SALV_TREE

Postby Deeler Stan » Tue May 12, 2009 9:14 am

Has anyone managed to use class CL_SALV_TREE and display icons in the data part of the tree.

If so, can you please give me an idea as to how to do this.

I thought it would be a case of doing the same as CL_SALV_TABLE getting the column and using method SET_ICON, but this does not exist in CL_SALV_TREE

Cheers Stan
Deeler Stan
Posts: 410
Joined: Thu Mar 31, 2005 3:44 am

Re: Icons using CL_SALV_TREE

Postby skarkada » Wed Apr 02, 2014 2:47 pm

I know this is 6 years too late. Since I struggled with this for several hours, I thought I will post the answer here so it will help someone else. Here is the solution to the problem (look for "<<):
Code: Select all
FORM add_tree_node  USING    p_related_node TYPE lvc_nkey
                             p_data         TYPE rspcchain
                    CHANGING p_new_node     TYPE lvc_nkey.

  DATA: nodes     TYPE REF TO cl_salv_nodes,
        node      TYPE REF TO cl_salv_node,
        item      TYPE REF TO cl_salv_item,
        text      TYPE lvc_value,
        icon      TYPE salv_de_tree_image.

  MOVE-CORRESPONDING p_data TO wa_display.
  READ TABLE gt_types INTO wa_type
    WITH KEY type = p_data-type
  IF sy-subrc = 0.
    wa_display-type_icon = wa_type-icon.
    wa_display-type_desc = wa_type-description.

  nodes = gr_tree->get_nodes( ).

      node = nodes->add_node( related_node = p_related_node
                              data_row     = wa_display
                              relationship = cl_gui_column_tree=>relat_last_child ).

      p_new_node = node->get_key( ).

      text = p_data-chain_id.
      node->set_text( text ).

      item = node->get_item( 'TYPE_ICON' ).  "<<
      icon = wa_display-type_icon.           "<<
      item->set_icon( icon ).                "<<

    CATCH cx_salv_msg.
ENDFORM.                    " ADD_TREE_NODE
Sudhi Karkada
Posts: 701
Joined: Mon Oct 21, 2002 1:12 pm
Location: Houston, TX, USA

Return to ABAP

Who is online

Users browsing this forum: No registered users and 5 guests



This website is not affiliated with, sponsored by, or approved by SAP AG.