Application Development and Automation 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: 
Read only

ALV Tree: match node to object reference

fenja_schulz
Advisor
Advisor
0 Likes
670

Hello,

could anyone help me with matching the node shown in the ALV tree with the object reference that contained the data.

In my program I create a hierarchie of objects of different local classes. Then I show this hierarchie using cl_gui_alv_tree on the UI. When someone clicks on one of the nodes I want to show more attributes of the object that is represented by the node. My problem is that I do have a node_key but no way to find out which object the node represents. Is there any way to match the two?

In a different programming language they solved the problem this way: Every node has an attribute called "data" where I can put in whatever I want, for example a reference to an object. Is there any such thing in ABAP or is there any other best practise on how to match the data source withe the node showing the data?

Thank you in advance.

Best regards,

Fenja

2 REPLIES 2
Read only

former_member201285
Active Participant
0 Likes
616

Hi Fenja,

as the click-events only raise the node_key (at least I couldn't detect another information), I assume the only way is maintaining an internal helper table by yourself which you build up in parallel when creating the tree and its nodes.

The (hashed) table might contain 2 columns:

1. node_key (as table key)

2. reference to an object

When a click-event is raised, you look up the corresponding object reference in your table.

Regards,

Ulrich

Read only

Former Member
0 Likes
616

What worked for me is during the build of node, I am concatenating the unique values of the itab into the node_key.  This way, I can point back to the actual record by splitting the value and retrieving the correct itab entry.