Multi Level Tree ALV with CL_GUI_SIMPLE_TREE


 


DATA :   lr_cust TYPE REF TO cl_gui_custom_container,
lr_tree TYPE REF TO cl_gui_simple_tree,
lt_scarr TYPE TABLE OF scarr,
ls_scarr TYPE scarr,
lt_spfli TYPE TABLE OF spfli,
ls_spfli TYPE spfli,
lt_node TYPE TABLE OF mtreesnode,
ls_node TYPE mtreesnode.

START-OF-SELECTION.
CALL SCREEN 0001.
*&———————————————————————*
*&      Module  STATUS_0001  OUTPUT
*&———————————————————————*

MODULE status_0001 OUTPUT.
SET PF-STATUS ‘STATUS’.
*  SET TITLEBAR ‘xxx’.
ENDMODULE.                 ” STATUS_0001  OUTPUT
*&———————————————————————*
*&      Module  GET_DATA  OUTPUT
*&———————————————————————*
MODULE get_data OUTPUT.
IF lt_scarr IS INITIAL.
SELECT FROM scarr INTO TABLE lt_scarr.
IF lt_scarr IS NOT INITIAL.
SELECT FROM spfli INTO TABLE lt_spfli FOR ALL ENTRIES IN lt_scarr WHERE carrid lt_scarrcarrid.
ENDIF.
ENDIF.
ENDMODULE.                 ” GET_DATA  OUTPUT
*&———————————————————————*
*&      Module  BUILD_TREE  OUTPUT
*&———————————————————————*
MODULE build_tree OUTPUT.
IF lr_cust IS NOT BOUND.
CREATE OBJECT lr_cust
EXPORTING
container_name              ‘SIMPLE_TREE’
repid                       syrepid
dynnr                       sydynnr
EXCEPTIONS
cntl_error                  1
cntl_system_error           2
create_error                3
lifetime_error              4
lifetime_dynpro_dynpro_link 5
OTHERS                      6.

ENDIF.
IF lr_tree IS NOT BOUND.
CREATE OBJECT lr_tree
EXPORTING
parent                      lr_cust
node_selection_mode         cl_gui_simple_tree=>node_sel_mode_single
EXCEPTIONS
lifetime_error              1
cntl_system_error           2
create_error                3
failed                      4
illegal_node_selection_mode 5
OTHERS                      6.
ENDIF.

IF lr_tree IS BOUND.
CLEAR ls_node.
ls_nodenode_key ‘ROOT’.
ls_nodeisfolder ‘X’.
ls_nodetext ‘Flight Info’.
APPEND ls_node TO lt_node.
LOOP AT lt_scarr INTO ls_scarr.
CLEAR ls_node.
ls_nodenode_key ls_scarrcarrid.
ls_noderelatkey ‘ROOT’.
ls_noderelatship cl_gui_simple_tree=>relat_last_child.
ls_nodeisfolder ‘X’.
ls_noden_image ‘@7T@’“ICON_WS_PLANE
ls_nodetext ls_scarrcarrname.
APPEND ls_node TO lt_node.

LOOP AT lt_spfli INTO ls_spfli WHERE carrid ls_scarrcarrid.
CLEAR ls_node.
ls_nodenode_key ls_spfliconnid.
ls_noderelatkey ls_scarrcarrid.
ls_noderelatship cl_gui_simple_tree=>relat_last_child.
ls_nodeisfolder ‘ ‘.
ls_noden_image ‘@7T@’“ICON_WS_PLANE
CONCATENATE ls_spflicountryfr
‘ – ‘ ls_spflicityfrom
‘ – ‘ ls_spflicountryto
‘ – ‘ ls_spflicityto INTO ls_nodetext SEPARATED BY space.
APPEND ls_node TO lt_node.
ENDLOOP.
ENDLOOP.

CALL METHOD lr_tree->add_nodes
EXPORTING
table_structure_name           ‘SCARR’
node_table                     lt_node
EXCEPTIONS
error_in_node_table            1
failed                         2
dp_error                       3
table_structure_name_not_found 4
OTHERS                         5.
ENDIF.

ENDMODULE.                 ” BUILD_TREE  OUTPUT
*&———————————————————————*
*&      Module  USER_COMMAND_0001  INPUT
*&———————————————————————*
MODULE user_command_0001 INPUT.
CASE syucomm.
WHEN ‘BACK’ OR ‘EXIT’ OR ‘CANCEL’.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE.                 ” USER_COMMAND_0001  INPUT


Screen flow logic.

 Execute the program.


 

 

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s