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 Double Click Functionality

Former Member
0 Kudos

I'm using an ALV tree grid to display a bunch of document headers and I'd like to add functionality when one such row is double clicked that a popup details window opens with additional data, preferably a grid like view of line items. Does anyone have input on how to use method handle_item_double_click to accommodate such a request?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try the below example program in SE38.

BCALV_GRID_DND_TREE ALV Grid: Drag and Drop with ALV Tree

BCALV_GRID_DND_TREE_SIMPLE ALV GRID: Drag and drop with ALV tree (simple)

BCALV_TEST_COLUMN_TREE Program BCALV_TEST_COLUMN_TREE

BCALV_TEST_SIMPLE_TREE Program BCALV_TEST_SIMPLE_TREE

BCALV_TREE_01 ALV Tree Control: Build Up the Hierarchy Tree

BCALV_TREE_02 ALV Tree Control: Event Handling

BCALV_TREE_03 ALV Tree Control: Use an Own Context Menu

BCALV_TREE_04 ALV Tree Control: Add a Button to the Toolbar

BCALV_TREE_05 ALV Tree Control: Add a Menu to the Toolbar

BCALV_TREE_06 ALV tree control: Icon column and icon for nodes/it

BCALV_TREE_DEMO Demo for ALV tree control

BCALV_TREE_DND ALV tree control: Drag & Drop within a hierarchy tr

BCALV_TREE_DND_MULTIPLE ALV tree control: Drag & Drop within a hierarchy tr

BCALV_TREE_EVENT_RECEIVER Include BCALV_TREE_EVENT_RECEIVER

BCALV_TREE_EVENT_RECEIVER01

BCALV_TREE_ITEMLAYOUT ALV Tree: Change Item Layouts at Runtime

BCALV_TREE_MOVE_NODE_TEST Demo for ALV tree control

BCALV_TREE_SIMPLE_DEMO Program BCALV_TREE_SIMPLE_DEMO

BCALV_TREE_VERIFY Verifier for ALV Tree and Simple ALV Tree

Regards,

Boobalan S

3 REPLIES 3

Former Member
0 Kudos

Hi,

check with sap standard program.

1.BCALV_TREE_02

2.BCALV_TREE_EVENT_RECEIVER

3.BCALV_TREE_EVENT_RECEIVER01

thanks,

Sendil

Former Member
0 Kudos

Hi,

Try the below example program in SE38.

BCALV_GRID_DND_TREE ALV Grid: Drag and Drop with ALV Tree

BCALV_GRID_DND_TREE_SIMPLE ALV GRID: Drag and drop with ALV tree (simple)

BCALV_TEST_COLUMN_TREE Program BCALV_TEST_COLUMN_TREE

BCALV_TEST_SIMPLE_TREE Program BCALV_TEST_SIMPLE_TREE

BCALV_TREE_01 ALV Tree Control: Build Up the Hierarchy Tree

BCALV_TREE_02 ALV Tree Control: Event Handling

BCALV_TREE_03 ALV Tree Control: Use an Own Context Menu

BCALV_TREE_04 ALV Tree Control: Add a Button to the Toolbar

BCALV_TREE_05 ALV Tree Control: Add a Menu to the Toolbar

BCALV_TREE_06 ALV tree control: Icon column and icon for nodes/it

BCALV_TREE_DEMO Demo for ALV tree control

BCALV_TREE_DND ALV tree control: Drag & Drop within a hierarchy tr

BCALV_TREE_DND_MULTIPLE ALV tree control: Drag & Drop within a hierarchy tr

BCALV_TREE_EVENT_RECEIVER Include BCALV_TREE_EVENT_RECEIVER

BCALV_TREE_EVENT_RECEIVER01

BCALV_TREE_ITEMLAYOUT ALV Tree: Change Item Layouts at Runtime

BCALV_TREE_MOVE_NODE_TEST Demo for ALV tree control

BCALV_TREE_SIMPLE_DEMO Program BCALV_TREE_SIMPLE_DEMO

BCALV_TREE_VERIFY Verifier for ALV Tree and Simple ALV Tree

Regards,

Boobalan S

former_member206439
Contributor
0 Kudos

Hi

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.