DATA : lr_cust TYPE REF TO cl_gui_custom_container,
lr_tree TYPE REF TO cl_gui_alv_tree,
lt_scarr TYPE TABLE OF scarr,
ls_scarr TYPE scarr,
lt_spfli TYPE TABLE OF spfli,
gt_spfli TYPE TABLE OF spfli,
ls_spfli TYPE spfli,
ls_header TYPE treev_hhdr,
lv_node_key1 TYPE lvc_nkey,
lv_node_key2 TYPE lvc_nkey,
lv_node_key3 TYPE lvc_nkey,
lv_node_text TYPE lvc_value.
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_scarr-carrid.
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 = 'ALV_TREE'
repid = sy-repid
dynnr = sy-dynnr
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_column_tree=>node_sel_mode_single
item_selection = 'X' " Can Individual Items be Selected?
no_toolbar = ' ' " NO_TOOLBAR
no_html_header = 'X' " NO_HTML_HEADER
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7
OTHERS = 8.
ENDIF.
* Prepairing Header
ls_header-heading = 'FLight Information'.
ls_header-tooltip = 'Flight Data'.
ls_header-width = 40.
ls_header-width_pix = ' '.
CALL METHOD lr_tree->set_table_for_first_display
EXPORTING
i_structure_name = 'SPFLI'
is_hierarchy_header = ls_header
CHANGING
it_outtab = gt_spfli. " table must be initial
* Prepairing Root node
lv_node_text = 'Flight Code'.
CALL METHOD lr_tree->add_node
EXPORTING
i_relat_node_key = ' '
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = lv_node_text
IMPORTING
e_new_node_key = lv_node_key1 " get the root node key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
* Create Hierarchy ( nodes )
LOOP AT lt_scarr INTO ls_scarr.
lv_node_text = ls_scarr-carrid.
CALL METHOD lr_tree->add_node
EXPORTING
i_relat_node_key = lv_node_key1 " pass the root node key
i_relationship = cl_gui_column_tree=>relat_last_child " How to Insert Node
i_node_text = lv_node_text " Hierarchy Node Text
IMPORTING
e_new_node_key = lv_node_key2 " Key of New Node Key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
LOOP AT lt_spfli INTO ls_spfli WHERE carrid = ls_scarr-carrid.
CALL METHOD lr_tree->add_node
EXPORTING
i_relat_node_key = lv_node_key2
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = ls_spfli
* is_node_layout = " Node Layout
* it_item_layout = " Item Layout
* i_node_text = " Hierarchy Node Text
IMPORTING
e_new_node_key = lv_node_key3 " Key of New Node Key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
ENDLOOP.
ENDLOOP.
* Must Call this method to display nodes on the container
CALL METHOD lr_tree->frontend_update.
ENDMODULE. " BUILD_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
------------------------------------------------------------------------------------------------------
Execute the program.
------------------------------------------------------------------
lr_tree TYPE REF TO cl_gui_alv_tree,
lt_scarr TYPE TABLE OF scarr,
ls_scarr TYPE scarr,
lt_spfli TYPE TABLE OF spfli,
gt_spfli TYPE TABLE OF spfli,
ls_spfli TYPE spfli,
ls_header TYPE treev_hhdr,
lv_node_key1 TYPE lvc_nkey,
lv_node_key2 TYPE lvc_nkey,
lv_node_key3 TYPE lvc_nkey,
lv_node_text TYPE lvc_value.
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_scarr-carrid.
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 = 'ALV_TREE'
repid = sy-repid
dynnr = sy-dynnr
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_column_tree=>node_sel_mode_single
item_selection = 'X' " Can Individual Items be Selected?
no_toolbar = ' ' " NO_TOOLBAR
no_html_header = 'X' " NO_HTML_HEADER
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7
OTHERS = 8.
ENDIF.
* Prepairing Header
ls_header-heading = 'FLight Information'.
ls_header-tooltip = 'Flight Data'.
ls_header-width = 40.
ls_header-width_pix = ' '.
CALL METHOD lr_tree->set_table_for_first_display
EXPORTING
i_structure_name = 'SPFLI'
is_hierarchy_header = ls_header
CHANGING
it_outtab = gt_spfli. " table must be initial
* Prepairing Root node
lv_node_text = 'Flight Code'.
CALL METHOD lr_tree->add_node
EXPORTING
i_relat_node_key = ' '
i_relationship = cl_gui_column_tree=>relat_last_child
i_node_text = lv_node_text
IMPORTING
e_new_node_key = lv_node_key1 " get the root node key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
* Create Hierarchy ( nodes )
LOOP AT lt_scarr INTO ls_scarr.
lv_node_text = ls_scarr-carrid.
CALL METHOD lr_tree->add_node
EXPORTING
i_relat_node_key = lv_node_key1 " pass the root node key
i_relationship = cl_gui_column_tree=>relat_last_child " How to Insert Node
i_node_text = lv_node_text " Hierarchy Node Text
IMPORTING
e_new_node_key = lv_node_key2 " Key of New Node Key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
LOOP AT lt_spfli INTO ls_spfli WHERE carrid = ls_scarr-carrid.
CALL METHOD lr_tree->add_node
EXPORTING
i_relat_node_key = lv_node_key2
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = ls_spfli
* is_node_layout = " Node Layout
* it_item_layout = " Item Layout
* i_node_text = " Hierarchy Node Text
IMPORTING
e_new_node_key = lv_node_key3 " Key of New Node Key
EXCEPTIONS
relat_node_not_found = 1
node_not_found = 2
OTHERS = 3.
ENDLOOP.
ENDLOOP.
* Must Call this method to display nodes on the container
CALL METHOD lr_tree->frontend_update.
ENDMODULE. " BUILD_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
------------------------------------------------------------------------------------------------------
Execute the program.
------------------------------------------------------------------
No comments:
Post a Comment