A Link Click is similar with a hotspot that when you hover your mouse, the cursor changes into a hand like this on the left. Then upon clicking on it, it will execute an action such as calling a new screen.
In this tutorial, I will discuss to you how to implement this functionality in ALV Report Tree using SAP ABAP OOP. I assumed however, that you have background knowledge now on how to manipulate ALV trees using Object Oriented concept. Otherwise, please stop and have some refresher first in OOP so that you have further understanding on how to control the ALV tree.
As can be seen into this screenshot above, the column Airline has a link click functionality. As I said, upon hovering your mouse, the cursor changes into a hand style. Actually, we can manipulate each node, if it has a link click functionality or none. So in this case, both LH and SQ have link click functionality under the Airline column.
1. Create a local class and define a method named "handle_link_click".
2. On the implementation of the method "handle_link_click" write any ABAP codes you want. In my example, I try to call a new screen, 201 which is in pop up mode using the keyword AT x-position y-position.
3. In the PBO of your main screen, let say screen 100, do the following additional steps. Normally, when creating the hierarchy tree, this is done after calling the method "set_table_for_first_display". This is the time you are adding the node to your ALV tree. During the node creation using the method "add_node", add the exporting parameter "it_item_layout".
4. In this next step you need to fill up the internal table "li_item_layout". First declare it accordingly. Then pass the name of the column where the link click will appear. In my example, I passed the field CARRID which represents the airline column. Finally, pass the value of the attribute "item_class_link" (which is 5 initially) from the class cl_gui_column_tree .
As I said above, we can manipulate each node of the ALV tree. If you want to show a link click of that particular node, pass the attribute item_class_link but if you want just to display the text without any link click of that node, pass the attribute item_class_text.
In my sample below, I just pass the attribute item_class_link to every node. Thus all nodes will have a link click effect. Please refer below for sample codes.
5. After doing so, register the event. This is needed so that the ALV tree will recognize the link click event, once triggered.
6. Once the event is registered, set handler to it. Please take note that the name of my local class in this tutorial is lcl_toolbar_event_receiver. So this might change depending on you.
7. Lastly, Save and Activate . Run your program and you will see the link click functionality in your ALV tree.
I Hope you enjoy this tutorial in implementing the link click functionality of ALV report in SAP ABAP using OOP method. For any clarifications and suggestions, please leave your comments below. I love to hear you guys.