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_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.
  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                       = 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_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_node-node_key = 'ROOT'.
    ls_node-isfolder = 'X'.
    ls_node-text = 'Flight Info'.
    APPEND ls_node TO lt_node.
    LOOP AT lt_scarr INTO ls_scarr.
      CLEAR ls_node.
      ls_node-node_key = ls_scarr-carrid.
      ls_node-relatkey = 'ROOT'.
      ls_node-relatship = cl_gui_simple_tree=>relat_last_child.
      ls_node-isfolder = ' '.
      ls_node-n_image = '@7T@'. "ICON_WS_PLANE
      ls_node-text = ls_scarr-carrname.
      APPEND ls_node TO lt_node.
    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 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