*----------------------------------------------------------------------
* CLASS CL_TREE_EVENTS DEFINITION
*----------------------------------------------------------------------
* [+] Class for handling events on o_tree
*----------------------------------------------------------------------
CLASS cl_tree_events DEFINITION.
PUBLIC SECTION.
METHODS:
handle_node_double_click
FOR EVENT node_double_click
OF cl_gui_simple_tree
IMPORTING node_key.
ENDCLASS. "cl_tree_events DEFINITION
*----------------------------------------------------------------------
* CLASS CL_TREE_EVENTS IMPLEMENTATION
*----------------------------------------------------------------------
* [+] Class for handling events on o_tree
*----------------------------------------------------------------------
CLASS cl_tree_events IMPLEMENTATION.
*---------------------------------------------------------------------*
* METHOD HANDLE_NODE_DOUBLE_CLICK
*---------------------------------------------------------------------*
* [+] Processes a double-click on a node
*---------------------------------------------------------------------*
METHOD handle_node_double_click.
WRITE: / node_key.
ENDMETHOD. "handle_node_double_click
ENDCLASS. "cl_tree_events IMPLEMENTATION
************************************************************************
***
*** MAIN PROCESSING
***
************************************************************************
************************************************************************
***
*** DOCKING AND TREE OBJECT METHODS
***
************************************************************************
*----------------------------------------------------------------------
* FORM BUILD_WINDOW
*----------------------------------------------------------------------
* [+] Constructs and loads the data into the window...
* [+] Builds the tree
* [+] Loads the tree nodes
*----------------------------------------------------------------------
FORM build_window.
* Local variables
DATA: li_events TYPE cntl_simple_events, "events
lv_events TYPE cntl_simple_event, "events
lv_repid TYPE syrepid. "report ID
* Setting variables
lv_repid = sy-repid.
* Create the tree object
CREATE OBJECT o_tree
EXPORTING
parent = parent_container
node_selection_mode = cl_gui_simple_tree=>node_sel_mode_single.
* Define the events to listen for
lv_events-eventid = cl_gui_simple_tree=>eventid_node_double_click.
lv_events-appl_event = 'X'. " process PAI if event occurs
APPEND lv_events TO li_events.
* Set the event listeners
SET HANDLER o_tree_listener->handle_node_double_click FOR o_tree.
* Build the tree
PERFORM build_tree.
ENDFORM. "build_window
*----------------------------------------------------------------------
* FORM BUILD_TREE
*----------------------------------------------------------------------
* [+] Loads the tree nodes
*----------------------------------------------------------------------
FORM build_tree.
* NODES ARE INSERTED IN THE ORDER SHOWN.
* DO NOT DEFINE A CHILD BEFORE ITS PARENT NODE!
* First Branch
* folder code parent image name
PERFORM add_node USING 'X' 'Child1' 'Root' '' 'Child Node 1'.
PERFORM add_node USING ' ' 'Leaf1' 'Child1' '' 'Leaf Node 1'.
PERFORM add_node USING ' ' 'Leaf2' 'Child1' '@10@' 'Leaf Node 2'.
* Second Branch
* folder code parent image name
PERFORM add_node USING 'X' 'Child2' 'Root' '' 'Child Node 2'.
PERFORM add_node USING ' ' 'Leaf3' 'Child2' '' 'Leaf Node 3'.
* Adds the nodes to the tree.
CALL METHOD o_tree->add_nodes
EXPORTING
table_structure_name = 'MTREESNODE'
node_table = i_nodes.
ENDFORM. "build_tree
*----------------------------------------------------------------------
* FORM ADD_NODE
*----------------------------------------------------------------------
* [+] Adds a node to the tree
*----------------------------------------------------------------------
FORM add_node
USING
p_folder TYPE c
p_code TYPE c
p_parent TYPE c
p_image TYPE c
p_name TYPE c.
*----------------------------------------------------------------------
* MODULE LOAD_TREE
*----------------------------------------------------------------------
* [+] Loads the tree
*----------------------------------------------------------------------
MODULE load_tree OUTPUT.
SET PF-STATUS 'MAIN'.
IF o_tree IS INITIAL.
* build the tree
PERFORM build_window.
ENDIF.
ENDMODULE. "load_tree OUTPUT
*----------------------------------------------------------------------
* MODULE PROCESS_EVENTS_0100
*----------------------------------------------------------------------
* [+] Processes the events from the dock/tree
*----------------------------------------------------------------------
MODULE process_events_0100 INPUT.
DATA: lv_tree_return_code TYPE i.
* If the tree made an event that affects PAI,
* then dont process the event here.
CALL METHOD cl_gui_cfw=>dispatch
IMPORTING
return_code = lv_tree_return_code.
IF lv_tree_return_code <> cl_gui_cfw=>rc_noevent.
CLEAR v_ok_code.
EXIT.
ENDIF.
CASE v_ok_code.
WHEN 'BACK'.
CLEAR o_tree.
LEAVE TO SCREEN 0.
ENDCASE.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.