DATA : lr_cust TYPE REF TO cl_gui_custom_container,
lr_list_tree TYPE REF TO cl_gui_list_tree,
lt_flight TYPE TABLE OF scarr,
ls_flight TYPE scarr,
lt_node TYPE treev_ntab,
ls_node TYPE LINE OF treev_ntab,
lt_item TYPE TABLE OF mtreeitm,
ls_item TYPE mtreeitm .
START-OF-SELECTION.
CALL SCREEN 0001.
*&---------------------------------------------------------------------*
*& Module STATUS_0001 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0001 OUTPUT.
SET PF-STATUS 'LIST_STATUS'.
ENDMODULE. " STATUS_0001 OUTPUT
*&---------------------------------------------------------------------*
*& Module GET_DATA OUTPUT
*&---------------------------------------------------------------------*
MODULE get_data OUTPUT.
IF lt_flight IS INITIAL.
SELECT * FROM scarr INTO TABLE lt_flight.
ENDIF.
ENDMODULE. " GET_DATA OUTPUT
*&---------------------------------------------------------------------*
*& Module BUILD_LIST_TREE OUTPUT
*&---------------------------------------------------------------------*
MODULE build_list_tree OUTPUT.
IF lr_cust IS NOT BOUND.
CREATE OBJECT lr_cust
EXPORTING
container_name = 'LIST_TREE'
repid = sy-repid
dynnr = sy-dynnr.
ENDIF.
IF lr_list_tree IS NOT BOUND.
CREATE OBJECT lr_list_tree
EXPORTING
parent = lr_cust
node_selection_mode = cl_gui_list_tree=>node_sel_mode_single
* hide_selection = " Visibility of Selection
item_selection = 'X' " Can Individual Items be Selected?
with_headers = ' ' " 'X': With Headers
* hierarchy_header = " Hierarchy Header
* list_header = " List Header
* name = " Name
EXCEPTIONS
lifetime_error = 1
cntl_system_error = 2
create_error = 3
illegal_node_selection_mode = 4
failed = 5
OTHERS = 6.
ENDIF.
IF lr_list_tree IS BOUND.
* Building Root Node
ls_node-node_key = 'Flight'.
ls_node-hidden = ' '.
ls_node-hidden = ' '.
ls_node-isfolder = 'X'.
APPEND ls_node TO lt_node.
* Building sub node and relationship with root node
LOOP AT lt_flight INTO ls_flight.
ls_node-node_key = ls_flight-carrid.
ls_node-relatkey = 'Flight'.
ls_node-relatship = cl_gui_list_tree=>relat_last_child.
ls_node-isfolder = ' '.
APPEND ls_node TO lt_node.
ENDLOOP.
* Building root Node Text
ls_item-node_key = 'Flight'.
ls_item-item_name = '1'.
ls_item-class = cl_gui_list_tree=>item_class_text.
ls_item-alignment = cl_gui_list_tree=>align_auto.
ls_item-font = cl_gui_list_tree=>item_font_prop.
ls_item-text = 'Flight_Info'.
APPEND ls_item TO lt_item.
* Bulding all Item node text
LOOP AT lt_flight INTO ls_flight.
ls_item-node_key = ls_flight-carrid.
ls_item-item_name = '1'.
ls_item-class = cl_gui_list_tree=>item_class_text.
ls_item-alignment = cl_gui_list_tree=>align_auto.
ls_item-font = cl_gui_list_tree=>item_font_prop.
ls_item-text = ls_flight-carrname.
APPEND ls_item TO lt_item.
ENDLOOP.
CALL METHOD lr_list_tree->add_nodes_and_items
EXPORTING
node_table = lt_node
item_table = lt_item
item_table_structure_name = 'MTREEITM'
EXCEPTIONS
failed = 1
cntl_system_error = 2
error_in_tables = 3
dp_error = 4
table_structure_name_not_found = 5
OTHERS = 6.
ENDIF.
ENDMODULE. " BUILD_LIST_TREE OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0001 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0001 INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0001 INPUT
Serkan AKKAVAK
Computer Engineer
SAP Department Deputy Manager
Contact : serkurumsal@yandex.com
Social Plugin