4

I created an ALV TREE report, using cl_gui_alv_tree, that has 3 levels. I'm also implementing an event handler for when he double clicks a node.

My problem is that I want to take some actions only when he double clicks a node that is a root node. The event 'node_double_click' gives a node_key, but that's the index of the displayed table. How could I achieve this?

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
Laloski
  • 71
  • 1
  • 2
  • 3

2 Answers2

2

The node ID is not an index, it's the ID you assigned to the node when adding it to the tree.

If possible, I'd suggest switching to CL_SALV_TREE - not only because it is documented and supported by SAP, but also because it comes with some query methods that are quite handy. These methods are documented as well. You can use, for example, GET_NODE to retrieve a node by its ID and then use GET_PARENT to check whether the node in question is a top-level node or has a parent node it is attached to.

vwegert
  • 18,371
  • 3
  • 37
  • 55
1

I created a pattern for myself, which i am using.

        lv_parent1 = node_key.

    while lv_parent1 ne go_Main_tree->C_VIRTUAL_ROOT_NODE.
      CALL METHOD go_main_tree->get_parent
        EXPORTING
          i_node_key        = lv_parent1
        IMPORTING
          e_parent_node_key = lv_parent1.

         lv_hierlevel   = lv_hierlevel + 1 .

     ENDWHILE.

    if lv_hierlevel > 2.
        “ do what You want to do
    endif.
icbytes
  • 1,831
  • 1
  • 17
  • 27