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

Former Member
0 Kudos

Hi ,

i have populated the ALV Tree and im trying to get the value of the selected field(in other words value of the field which i click),

but im not sure which method to use.

Please could any one help me on this regard?

Thanks in advance.

sorry for cross posting the other threads were deleted.

4 REPLIES 4

naimesh_patel
Active Contributor
0 Kudos

Check Program SAPTLIST_TREE_CONTROL_DEMO

Specially class LCL_APPLICATION and how does it used to SET the events of the tree.

Regards,

Naimesh Patel

former_member745780
Active Participant
0 Kudos

Hello,

use this method


CALL METHOD me->tree_get_node_text
  EXPORTING
    i_node_key  =  node_key
  IMPORTING
    E_NODE_TEXT = text
    .

Thanks

Anirudh Saini

former_member206439
Contributor
0 Kudos

Hi

see this for button clicking

In order to add additional buttons onto the ALVtree report the following sections of code need

implementing:

Creation of tree event reciever class

Define class to handle user interaction other than via toolbar buttons. Insert at end of DATA declaration

section but before any ABAP processing.

----


  • INCLUDE BCALV_TREE_EVENT_RECEIVER *

----


CLASS lcl_tree_event_receiver DEFINITION.

PUBLIC SECTION.

METHODS handle_node_ctmenu_request

FOR EVENT node_context_menu_request OF cl_gui_alv_tree

IMPORTING node_key

menu.

METHODS handle_node_ctmenu_selected

FOR EVENT node_context_menu_selected OF cl_gui_alv_tree

IMPORTING node_key

fcode.

METHODS handle_item_ctmenu_request

FOR EVENT item_context_menu_request OF cl_gui_alv_tree

IMPORTING node_key

fieldname

menu.

METHODS handle_item_ctmenu_selected

FOR EVENT item_context_menu_selected OF cl_gui_alv_tree

IMPORTING node_key

fieldname

fcode.

METHODS handle_item_double_click

FOR EVENT item_double_click OF cl_gui_alv_tree

IMPORTING node_key

fieldname.

METHODS handle_button_click

FOR EVENT button_click OF cl_gui_alv_tree

IMPORTING node_key

fieldname.

METHODS handle_link_click

FOR EVENT link_click OF cl_gui_alv_tree

IMPORTING node_key

fieldname.

METHODS handle_header_click

FOR EVENT header_click OF cl_gui_alv_tree

IMPORTING fieldname.

ENDCLASS.

----


  • CLASS lcl_tree_event_receiver IMPLEMENTATION

----


  • ........ *

----


CLASS lcl_tree_event_receiver IMPLEMENTATION.

METHOD handle_node_ctmenu_request.

  • append own functions

CALL METHOD menu->add_function

EXPORTING fcode = 'USER1'

text = 'Usercmd 1'. "#EC NOTEXT

CALL METHOD menu->add_function

EXPORTING fcode = 'USER2'

text = 'Usercmd 2'. "#EC NOTEXT

CALL METHOD menu->add_function

EXPORTING fcode = 'USER3'

text = 'Usercmd 3'. "#EC NOTEXT

ENDMETHOD.

METHOD handle_node_ctmenu_selected.

CASE fcode.

WHEN 'USER1' OR 'USER2' OR 'USER3'.

MESSAGE i000(0h) WITH 'Node-Context-Menu on Node ' node_key

'fcode : ' fcode. "#EC NOTEXT

ENDCASE.

ENDMETHOD.

METHOD handle_item_ctmenu_request .

  • append own functions

CALL METHOD menu->add_function

EXPORTING fcode = 'USER1'

text = 'Usercmd 1'.

CALL METHOD menu->add_function

EXPORTING fcode = 'USER2'

text = 'Usercmd 2'.

CALL METHOD menu->add_function

EXPORTING fcode = 'USER3'

text = 'Usercmd 3'.

ENDMETHOD.

METHOD handle_item_ctmenu_selected.

CASE fcode.

WHEN 'USER1' OR 'USER2' OR 'USER3'.

MESSAGE i000(0h) WITH 'Item-Context-Menu on Node ' node_key

'Fieldname : ' fieldname. "#EC NOTEXT

ENDCASE.

ENDMETHOD.

METHOD handle_item_double_click.

  • Processing for when user double clicks on ALVtree

ENDMETHOD.

METHOD handle_button_click.

  • Processing when user clicks button

ENDMETHOD.

METHOD handle_link_click.

  • ??

ENDMETHOD.

METHOD handle_header_click.

  • Processing for when user clicks on ALVtree column headers

ENDMETHOD.

ENDCLASS.

Code to activate User interaction events (i.e. double click)

Insert the following code into the PBO of the screen after the ALVtree has been created.

i.e after 'CALL METHOD gd_tree->set_table_for_first_display' has been executed.

&----


*& REGISTER_EVENTS

&----


  • define the events which will be passed to the backend

data: lt_events type cntl_simple_events,

l_event type cntl_simple_event.

  • define the events which will be passed to the backend

l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.

append l_event to lt_events.

l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.

append l_event to lt_events.

l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.

append l_event to lt_events.

l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.

append l_event to lt_events.

l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.

append l_event to lt_events.

l_event-eventid = cl_gui_column_tree=>eventid_item_double_click.

append l_event to lt_events.

l_event-eventid = cl_gui_column_tree=>eventid_header_click.

append l_event to lt_events.

l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.

append l_event to lt_events.

call method gd_tree->set_registered_events

exporting

events = lt_events

exceptions

cntl_error = 1

cntl_system_error = 2

illegal_event_combination = 3.

if sy-subrc <> 0.

message x208(00) with 'ERROR'. "#EC NOTEXT

endif.

  • set Handler

data: l_event_receiver type ref to lcl_tree_event_receiver.

create object l_event_receiver.

set handler l_event_receiver->handle_node_ctmenu_request

for gd_tree.

set handler l_event_receiver->handle_node_ctmenu_selected

for gd_tree.

set handler l_event_receiver->handle_item_ctmenu_request

for gd_tree.

set handler l_event_receiver->handle_item_ctmenu_selected

for gd_tree.

set handler l_event_receiver->handle_item_double_click

for gd_tree.

set handler l_event_receiver->handle_header_click

for gd_tree.

Former Member
0 Kudos

Hi

Thanx for the help, but the method

call method me->tree_get_node_text

exporting

i_node_key = l_node_key

importing

e_node_text = e_node_text.

is private so we need to call a public or protected method to use the above one.