S_ALR_87012284 -  List Output - ALV Tree Control

Dear Friends,
In Standard Financial statement report when I use List output  -> ALV Tree Control  lay out. In the display area is it possible to save the expanded folders  in lay out. So that next time when I run the report with the same ALV Tree Contorl lay out, I would like to see folders expanded.
Thanks,
Venky

Hi Venky,
There is no way to have expanded tree list. You must hit Expand tree button to.
You can also use ttrasaction code F.01 for balance sheet.
Best regards

Similar Messages

  • TRIAL BALANCE WITH  ALV TREE CONTROL

    Hi Friends,
    My manager wants to see trial balance with cost centers like ALV tree control display.
    Does SAP have any Std trial balance report which can show cost centers also for accounts and activities within those cost centers.
    Please help.
    Thanks

    Nelow message will appear and not possible technically
    Output option ALV Tree Control: Parameter Scaling set to 0/0
    Message no. FR098
    Diagnosis
    You selected output option ALV Tree Control. For technical reasons, only  the value 0/0 is possible for the parameter Scaling.
    System Response
    Parameter Scaling set to the value 0/0.
    Procedure
    If you want to compare the program output for output options ALV Tree Control and Classical list, you have to also set the parameter Scaling  to '0/0' when running the program with output option Classical list.

  • Scaling in F.01 with ALV Tree Control

    Hi Experts,
    Is there any possibility of generating the financial statements in F.01 in ALV tree control with amount scaled to 3 or 5 zero's. When i try to use ALV with scaling, the scaling is reset to 0
    Thanks in Advance

    Nelow message will appear and not possible technically
    Output option ALV Tree Control: Parameter Scaling set to 0/0
    Message no. FR098
    Diagnosis
    You selected output option ALV Tree Control. For technical reasons, only  the value 0/0 is possible for the parameter Scaling.
    System Response
    Parameter Scaling set to the value 0/0.
    Procedure
    If you want to compare the program output for output options ALV Tree Control and Classical list, you have to also set the parameter Scaling  to '0/0' when running the program with output option Classical list.

  • Drop down list in alv tree

    Hi,
    I am developing an ALV TREE. I need help Its really urgent. In the output screen there will be 2 level nodes. in the item line 1 field should be input enabled using which the database table is to be modified.when user left clicks on this field a drop down list will appear from which he selects his choice.
    I looked into BCALV_TREE_SIMPLE_DEMO reports available in SAP.
    I would also like to know what is register_events, what is an handler.
    help me.
    Edited by: Sudipa Das on Oct 4, 2008 11:53 AM
    Edited by: Sudipa Das on Oct 4, 2008 11:53 AM
    Edited by: Sudipa Das on Oct 4, 2008 11:54 AM

    Hello Sudipa
    I do not think you can have editable fields other than checkboxes in ALV trees. In sample report ZUS_SDN_ALV_TREE_DEMO_1 I have set the fieldcatalog property LS_FCAT-EDIT = 'X' for all fields yet only LOEVM is editable because it is defined as checkbox, too.
    However, you may use the LINK_CLICK of the ALV tree (set LS_FCAT-HOTSPOT = 'X' in fieldcatalog) to trigger e.g. a seach help for input.
    *& Report  ZUS_SDN_ALV_TREE_DEMO
    *& Thread: drop down list in alv tree
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1074082"></a>
    *& Thread: alv tree checbox problem when attempt to get the selected checjboxes
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1050473"></a>
    *& Thread: alv tree checkbox problem
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1046535"></a>
    *& Thread: double click in ALV tree output????
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="742412"></a>
    *& Flow logic of screen '0100' (contains no screen elements):
    **  PROCESS BEFORE OUTPUT.
    **    MODULE STATUS_0100.
    **  PROCESS AFTER INPUT.
    **    MODULE USER_COMMAND_0100.
    *& user-command (for command window): DISPLAY, SELECTED_NODES
    REPORT  zus_sdn_alv_tree_demo_1.
    CLASS cl_gui_column_tree DEFINITION LOAD.
    CLASS cl_gui_cfw DEFINITION LOAD.
    TYPE-POOLS: abap, shlp.
    TYPES: BEGIN OF ty_s_key.
    TYPES: nkey       TYPE lvc_nkey.
    TYPES: parent_key TYPE lvc_nkey.
    TYPES: END OF ty_s_key.
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE TYPE knvv AS data.
    INCLUDE TYPE ty_s_key AS key.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA: gt_outtab    TYPE ty_t_outtab.
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syst-repid,
      gt_fcat          TYPE lvc_t_fcat,
      gs_layout        TYPE lvc_s_layo,
      gs_variant       TYPE disvariant,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_tree          TYPE REF TO cl_gui_alv_tree.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
        handle_node_double_click
          FOR EVENT node_double_click OF cl_gui_alv_tree
          IMPORTING node_key,
        handle_item_double_click
          FOR EVENT item_double_click OF cl_gui_alv_tree
          IMPORTING node_key
                    fieldname,
        handle_checkbox_change
          FOR EVENT checkbox_change OF cl_gui_alv_tree
          IMPORTING checked
                    fieldname
                    node_key,
        handle_link_click
          FOR EVENT link_click OF cl_gui_alv_tree
          IMPORTING fieldname
                    node_key.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_node_double_click.
        MESSAGE 'Event=Double-Click on Node' TYPE 'I'.
        CALL TRANSACTION 'XD03'.
      ENDMETHOD.                    "handle_node_double_click
      METHOD handle_item_double_click.
        MESSAGE 'Event=Double-Click on Item' TYPE 'I'.
        CALL TRANSACTION 'VA03'.
      ENDMETHOD.                    "handle_item_double_click
      METHOD handle_checkbox_change.
        DATA: ls_outtab     TYPE ty_s_outtab.
        BREAK-POINT.
        IF ( fieldname = 'LOEVM' ).
          CALL METHOD go_tree->get_outtab_line
            EXPORTING
              i_node_key     = node_key
            IMPORTING
              e_outtab_line  = ls_outtab
    *          e_node_text    =
    *          et_item_layout =
    *          es_node_layout =
            EXCEPTIONS
              node_not_found = 1
              OTHERS         = 2.
          IF sy-subrc <> 0.
    *       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          ls_outtab-loevm = checked.
          MODIFY gt_outtab FROM ls_outtab
            TRANSPORTING loevm
            WHERE ( nkey = node_key ).
        ENDIF.
        " Trigger PAI
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'REFRESH'
    *        IMPORTING
    *          rc       =
      ENDMETHOD.                    "handle_checkbox_change
      METHOD handle_link_click.
        data: ls_shlp         type SHLP_DESCR,
              lt_retvalues    type STANDARD TABLE OF DDSHRETVAL.
        BREAK-POINT.
        CALL FUNCTION 'F4IF_GET_SHLP_DESCR'
          EXPORTING
            shlpname       = 'USER_COMP'
    *       SHLPTYPE       = 'SH'
          IMPORTING
            SHLP           = ls_shlp.
        CALL FUNCTION 'F4IF_START_VALUE_REQUEST'
          EXPORTING
            shlp                = ls_shlp
    *       DISPONLY            = ' '
    *       MAXRECORDS          = 500
    *       MULTISEL            = ' '
    *       CUCOL               = SY-CUCOL
    *       CUROW               = SY-CUROW
    *     IMPORTING
    *       RC                  =
          tables
            return_values       = lt_retvalues.
      ENDMETHOD.                    "handle_link_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      PERFORM init_controls.
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      container                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 3
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL SCREEN '0100'.
    ** NOTE: no elements on screen
    **  PROCESS BEFORE OUTPUT.
    **    MODULE STATUS_0100.
    **  PROCESS AFTER INPUT.
    **    MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      TRANSLATE gd_okcode TO UPPER CASE.
      CASE gd_okcode.
        WHEN 'BACK'  OR
             'EXIT'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'REFRESH'.
          CALL METHOD go_tree->update_calculations
    *        EXPORTING
    *          no_frontend_update =
        WHEN 'SELECTED_NODES'.
          PERFORM get_selected_nodes.
        WHEN 'DISPLAY'.
          PERFORM display.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  init_controls
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          OTHERS = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * create tree control
      CREATE OBJECT go_tree
        EXPORTING
          parent                      = go_docking
          node_selection_mode         = cl_gui_column_tree=>node_sel_mode_multiple
          item_selection              = 'X'  " required for double-click event on item
          no_html_header              = ''
          no_toolbar                  = ''
        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.
      IF sy-subrc <> 0.
        MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
      ENDIF.
    * create Hierarchy-header
      DATA ls_hierarchy_header TYPE treev_hhdr.
      PERFORM build_hierarchy_header CHANGING ls_hierarchy_header.
      PERFORM build_fieldcatalog.
      PERFORM set_layout_and_variant.
    * create emty tree-control
      CALL METHOD go_tree->set_table_for_first_display
        EXPORTING
    **      i_structure_name     = 'KNVV'
          is_variant           = gs_variant
          i_save               = 'A'
    *      i_default            = 'X'
          is_hierarchy_header  = ls_hierarchy_header
    *      is_exception_field   =
    *      it_special_groups    =
    *      it_list_commentary   =
    *      i_logo               =
    *      i_background_id      =
    *      it_toolbar_excluding =
    *      it_except_qinfo      =
        CHANGING
          it_outtab            = gt_outtab
    *      it_filter            =
          it_fieldcatalog      = gt_fcat.
    * create hierarchy
      PERFORM create_hierarchy.
    * register events
      PERFORM register_events.
    * adjust column_width
      CALL METHOD go_tree->column_optimize.
    ENDFORM.                    " init_controls
    *&      Form  build_hierarchy_header
    *       build hierarchy-header-information
    *      -->P_L_HIERARCHY_HEADER  strucxture for hierarchy-header
    FORM build_hierarchy_header CHANGING
                                   p_hierarchy_header TYPE treev_hhdr.
      p_hierarchy_header-heading = 'Hierarchy Header'.          "#EC NOTEXT
      p_hierarchy_header-tooltip =
                             'This is the Hierarchy Header !'.  "#EC NOTEXT
      p_hierarchy_header-width = 30.
      p_hierarchy_header-width_pix = ''.
    ENDFORM.                               " build_hierarchy_header
    *&      Form  BUILD_FIELDCATALOG
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog .
      DATA: ls_fcat   TYPE lvc_s_fcat.
      REFRESH: gt_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'KNVV'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
          i_bypassing_buffer           = 'X'
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      DELETE gt_fcat FROM 10.
      ls_fcat-tech = 'X'.
      MODIFY gt_fcat FROM ls_fcat
        TRANSPORTING tech
        WHERE ( key = 'X' ).
      ls_fcat-edit = 'X'.
      MODIFY gt_fcat FROM ls_fcat
        TRANSPORTING edit
        WHERE ( key NE 'X' ).
      READ TABLE gt_fcat INTO ls_fcat
           WITH KEY fieldname = 'LOEVM'.
      IF ( syst-subrc = 0 ).
        ls_fcat-checkbox = 'X'.
        ls_fcat-edit     = 'X'.
    **    ls_fcat-hotspot  = 'X'.
        MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
      ENDIF.
      READ TABLE gt_fcat INTO ls_fcat
           WITH KEY fieldname = 'ERNAM'.
      IF ( syst-subrc = 0 ).
        ls_fcat-hotspot  = 'X'.
        MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
      ENDIF.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  SET_LAYOUT_AND_VARIANT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_layout_and_variant .
      CLEAR: gs_layout,
             gs_variant.
      gs_variant-report = syst-repid.
      gs_variant-handle = 'TREE'.
    ENDFORM.                    " SET_LAYOUT_AND_VARIANT
    *&      Form  create_hierarchy
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_hierarchy .
      DATA: ls_knvv     TYPE sflight,
            ld_idx      TYPE i,
            ls_outtab   TYPE ty_s_outtab,
            lt_outtab   TYPE ty_t_outtab.
    * get data
      SELECT * FROM knvv INTO CORRESPONDING FIELDS OF TABLE lt_outtab
                            UP TO 20 ROWS .                 "#EC CI_NOWHERE
      SORT lt_outtab BY kunnr vkorg.
    * add data to tree
      DATA: ld_root_key  TYPE lvc_nkey,
            ld_kunnr_key TYPE lvc_nkey,
            ld_vkorg_key TYPE lvc_nkey,
            ld_last_key  TYPE lvc_nkey.
      ld_idx = 0.
      LOOP AT lt_outtab INTO ls_outtab.
        AT FIRST.
          PERFORM add_root_line USING    ls_outtab-data
                                  CHANGING ld_root_key.
          ADD 1 TO ld_idx.
          ls_outtab-nkey       = ld_root_key.
          ls_outtab-parent_key = space.
          MODIFY gt_outtab FROM ls_outtab INDEX ld_idx
            TRANSPORTING key.
        ENDAT.
        ON CHANGE OF ls_outtab-kunnr.
          PERFORM add_customer_line USING    ls_outtab-data
                                             ld_root_key
                                  CHANGING ld_kunnr_key.
          ADD 1 TO ld_idx.
          ls_outtab-nkey       = ld_kunnr_key.
          ls_outtab-parent_key = ld_root_key.
          MODIFY gt_outtab FROM ls_outtab INDEX ld_idx
            TRANSPORTING key.
        ENDON.
        ON CHANGE OF ls_outtab-vkorg.
          PERFORM add_salesorg_line USING    ls_outtab-data
                                             ld_kunnr_key
                                  CHANGING ld_vkorg_key.
          ADD 1 TO ld_idx.
          ls_outtab-nkey       = ld_vkorg_key.
          ls_outtab-parent_key = ld_kunnr_key.
          MODIFY gt_outtab FROM ls_outtab INDEX ld_idx
            TRANSPORTING key.
        ENDON.
        PERFORM add_complete_line USING  ls_outtab-data
                                         ld_vkorg_key
                                CHANGING ld_last_key.
        ADD 1 TO ld_idx.
        ls_outtab-nkey       = ld_last_key.
        ls_outtab-parent_key = ld_vkorg_key.
        MODIFY gt_outtab FROM ls_outtab INDEX ld_idx
          TRANSPORTING key.
      ENDLOOP.
    * calculate totals
      CALL METHOD go_tree->update_calculations.
    * this method must be called to send the data to the frontend
      CALL METHOD go_tree->frontend_update.
    ENDFORM.                    " create_hierarchy
    *&      Form  add_customer_line
    *       add hierarchy-level 1 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    FORM add_root_line USING     us_data TYPE ty_s_outtab-data
                                 ud_relat_key TYPE lvc_nkey
                         CHANGING  cd_node_key TYPE lvc_nkey.
      DATA: l_node_text TYPE lvc_value,
            ls_data TYPE ty_s_outtab-data.
    * set item-layout
      DATA: lt_item_layout TYPE lvc_t_layi,
            ls_item_layout TYPE lvc_s_layi.
      ls_item_layout-t_image = '@3Q@'.  " icon_overview
      ls_item_layout-fieldname = go_tree->c_hierarchy_column_name.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensifd_critical.
      APPEND ls_item_layout TO lt_item_layout.
    * add node
      l_node_text =  'Overview: Sales Areas'.
      DATA: ls_node TYPE lvc_s_layn.
      ls_node-n_image   = space.
      ls_node-exp_image = space.
      CALL METHOD go_tree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = l_node_text
          is_outtab_line   = ls_data
          is_node_layout   = ls_node
          it_item_layout   = lt_item_layout
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                               " add_root_line
    *&      Form  add_customer_line
    *       add hierarchy-level 1 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    FORM add_customer_line USING     us_data TYPE ty_s_outtab-data
                                     ud_relat_key TYPE lvc_nkey
                         CHANGING  cd_node_key TYPE lvc_nkey.
      DATA: l_node_text TYPE lvc_value,
            ls_data TYPE ty_s_outtab-data.
    * set item-layout
      DATA: lt_item_layout TYPE lvc_t_layi,
            ls_item_layout TYPE lvc_s_layi.
      ls_item_layout-t_image = '@A0@'.  " icon_customer.
      ls_item_layout-fieldname = go_tree->c_hierarchy_column_name.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensifd_critical.
      APPEND ls_item_layout TO lt_item_layout.
    * add node
      l_node_text =  us_data-kunnr.
      DATA: ls_node TYPE lvc_s_layn.
      ls_node-n_image   = space.
      ls_node-exp_image = space.
      CALL METHOD go_tree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = l_node_text
          is_outtab_line   = ls_data
          is_node_layout   = ls_node
          it_item_layout   = lt_item_layout
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                               " add_customer_line
    *&      Form  add_salesorg_line
    *       add hierarchy-level 1 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    FORM add_salesorg_line USING     us_data TYPE ty_s_outtab-data
                                     ud_relat_key TYPE lvc_nkey
                         CHANGING  cd_node_key TYPE lvc_nkey.
      DATA: l_node_text TYPE lvc_value,
            ls_data TYPE ty_s_outtab-data.
    * set item-layout
      DATA: lt_item_layout TYPE lvc_t_layi,
            ls_item_layout TYPE lvc_s_layi.
      ls_item_layout-t_image = '@DS@'.  " ICON_PARTNER_SALES_ACTIVITY
      ls_item_layout-fieldname = go_tree->c_hierarchy_column_name.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensifd_critical.
      APPEND ls_item_layout TO lt_item_layout.
    * add node
      l_node_text =  us_data-vkorg.
      DATA: ls_node TYPE lvc_s_layn.
      ls_node-n_image   = space.
      ls_node-exp_image = space.
      CALL METHOD go_tree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = l_node_text
          is_outtab_line   = ls_data
          is_node_layout   = ls_node
          it_item_layout   = lt_item_layout
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                               " add_salesorg_line
    *&      Form  add_cmplete_line
    *       add hierarchy-level 3 to tree
    *      -->P_LS_SFLIGHT  sflight
    *      -->P_RELEATKEY   relatkey
    *     <-->p_node_key    new node-key
    FORM add_complete_line USING     us_data TYPE ty_s_outtab-data
                                     ud_relat_key TYPE lvc_nkey
                         CHANGING  cd_node_key TYPE lvc_nkey.
      DATA: l_node_text TYPE lvc_value.
    * set item-layout
      DATA: lt_item_layout TYPE lvc_t_layi,
            ls_item_layout TYPE lvc_s_layi.
      ls_item_layout-fieldname = go_tree->c_hierarchy_column_name.
      ls_item_layout-class   = cl_gui_column_tree=>item_class_checkbox.
      ls_item_layout-editable = 'X'.
      APPEND ls_item_layout TO lt_item_layout.
    **  clear: ls_item_layout.
    **  ls_item_layout-fieldname = 'BEGRU'.
    **  ls_item_layout-class   = cl_gui_column_tree=>ITEM_CLASS_CHECKBOX.
    **  ls_item_layout-editable = 'X'.
    **  APPEND ls_item_layout TO lt_item_layout.
    **  CLEAR ls_item_layout.
    **  ls_item_layout-fieldname = 'PLANETYPE'.
    **  ls_item_layout-alignment = cl_gui_column_tree=>align_right.
    **  APPEND ls_item_layout TO lt_item_layout.
      l_node_text =  us_data-vtweg.
      DATA: ls_node TYPE lvc_s_layn.
      ls_node-n_image   = space.
      ls_node-exp_image = space.
      CALL METHOD go_tree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          is_outtab_line   = us_data
          i_node_text      = l_node_text
          is_node_layout   = ls_node
          it_item_layout   = lt_item_layout
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                               " add_complete_line
    *&      Form  register_events
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM register_events.
    * define the events which will be passed to the backend
      DATA: lt_events TYPE cntl_simple_events,
            l_event TYPE cntl_simple_event.
    * define the events which will be passed to the backend
      l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
      APPEND l_event TO lt_events.
    **  l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
    **  APPEND l_event TO lt_events.
    **  l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
    **  APPEND l_event TO lt_events.
    **  l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
    **  APPEND l_event TO lt_events.
    **  l_event-eventid = cl_gui_column_tree=>eventid_header_click.
    **  APPEND l_event TO lt_events.
    **  l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
    **  APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_node_double_click.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_double_click.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_link_click.
      APPEND l_event TO lt_events.
      CALL METHOD go_tree->set_registered_events
        EXPORTING
          events                    = lt_events
        EXCEPTIONS
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
      IF sy-subrc <> 0.
        MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
      ENDIF.
    * set Handler
      SET HANDLER:
        lcl_eventhandler=>handle_node_double_click FOR go_tree,
        lcl_eventhandler=>handle_item_double_click FOR go_tree,
        lcl_eventhandler=>handle_checkbox_change   FOR go_tree,
        lcl_eventhandler=>handle_link_click        FOR go_tree.
    **  DATA: l_event_receiver TYPE REF TO lcl_tree_event_receiver.
    **  CREATE OBJECT l_event_receiver.
    **  SET HANDLER l_event_receiver->handle_node_ctmenu_request
    **                                                        FOR tree1.
    **  SET HANDLER l_event_receiver->handle_node_ctmenu_selected
    **                                                        FOR tree1.
    **  SET HANDLER l_event_receiver->handle_item_ctmenu_request
    **                                                        FOR tree1.
    **  SET HANDLER l_event_receiver->handle_item_ctmenu_selected
    **                                                        FOR tree1.
    **  SET HANDLER l_event_receiver->handle_checkbox_change FOR tree1.
    ENDFORM.                               " register_events
    *&      Form  DISPLAY
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM display .
      DATA: ls_outtab   TYPE ty_s_outtab,
            ls_line     TYPE ty_s_outtab,
            ld_msg      TYPE bapi_msg.
      BREAK-POINT.
      LOOP AT gt_outtab INTO ls_outtab
              WHERE ( loevm = 'X' ).
        CONCATENATE 'Checkbox:'
                    ls_outtab-kunnr
                    ls_outtab-vkorg
                    ls_outtab-vtweg
                    ls_outtab-spart
                    ls_outtab-loevm
          INTO ld_msg SEPARATED BY space.
        MESSAGE ld_msg TYPE 'I'.
      ENDLOOP.
      IF ( syst-subrc NE 0 ).
        MESSAGE 'No marked checkboxes found' TYPE 'I'.
      ENDIF.
      PERFORM get_selected_nodes.
    ENDFORM.                    " DISPLAY
    *&      Form  GET_SELECTED_NODES
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM get_selected_nodes.
    * define local data
      DATA: ld_msg        TYPE bapi_msg,
            lt_nodes      TYPE lvc_t_nkey,
            ls_outtab     TYPE ty_s_outtab,
            ld_nkey       TYPE lvc_nkey,
            lt_items      TYPE lvc_t_layi,
            ls_item       TYPE lvc_s_layi.
      CALL METHOD go_tree->get_selected_nodes
        CHANGING
          ct_selected_nodes = lt_nodes
        EXCEPTIONS
          cntl_system_error = 1
          dp_error          = 2
          failed            = 3
          OTHERS            = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CHECK ( lt_nodes IS NOT INITIAL ).
      BREAK-POINT.
      LOOP AT lt_nodes INTO ld_nkey.
        CALL METHOD go_tree->get_outtab_line
          EXPORTING
            i_node_key     = ld_nkey
          IMPORTING
            e_outtab_line  = ls_outtab-data
    *        e_node_text    =
            et_item_layout = lt_items
    *        es_node_layout =
          EXCEPTIONS
            node_not_found = 1
            OTHERS         = 2.
        IF sy-subrc <> 0.
    *     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        LOOP AT lt_items INTO ls_item
                         WHERE ( chosen = 'X' ).
          CONCATENATE 'Item:'
                      ls_outtab-kunnr
                      ls_outtab-vkorg
                      ls_outtab-vtweg
                      ls_outtab-spart
                      ls_outtab-loevm
            INTO ld_msg SEPARATED BY space.
          MESSAGE ld_msg TYPE 'I'.
        ENDLOOP.
      ENDLOOP.
    ENDFORM.                    " GET_SELECTED_NODES
    Regards
      Uwe

  • ALV TREE CONTROL

    Hi experts,
        How to create tree node with folder symbol dynamically in alv tree control.
    Thanks
    Ramesh VR

    It is just a tree structure display in ALV output mode
    BCALV_TREE_DEMO Demo program for ALV tree control
    Many times in Finance there are requirements where User wants to see balance sheet report based on cost center groups and cost centres within it in this form

  • How to binding incoming xml node list to the tree control as dataProvider

    Recently, I faced into one issue: I want to binding incoming xml node (it's not avaliable at start) list to the tree control as a dataProvider.
    Since the incoming xml node list is not avaliable at beginning but I needs to bind it to the tree, so I create one virtual one in the xml, and prepare to remove it before the tree is shown. (ready for the actual node adding). But It did not work.
    Please see the presudo-code here:
    1.  Model layer(CsModel.as)
    public class CsModel
            [Bindable]
            public var treeXML:XML=<nodes><car label="virtualOne" id="1">
                                   </car></nodes>;
            (Here, I want to build binding relationship on the <car/> node,
             one 'virtual/stub' node is set here with lable="virtualOne".
             But this node will be deleted after IdTree
             control is created completely.)      
            [Bindable]
            public var treeData:XMLList =new XMLListCollection(treeXML.car);
    2. view layer(treePage.mxml)
            private var _model:CsModel = new CsModel();
            private function addNode():void
                    var newNode:XML=<car/>;
                    newNode.@label="newOne";
                    newNode.@id=1;
                    _model.treeXML.appendChild(newNode);
                             private function cleanData():void
                                     delete _model.treeXML.car;
            <mx:VBox height="100%" width="100%">
            <mx:Button label="AddNode" click="addNode()" />
            <mx:Tree id="IdTree"  labelField="@label"
              creationComplete="cleanData()"
              dataProvider="{_model}"/>
        </mx:VBox>
    3. Top view layer (App.Mxml)
    <mx:application>
        <treePage />
    </mx:application>
    For method: cleanData(),It's expected that when the treePage is shown, we first delete the virutalOne to provide one 'clear' tree since we don't want show virtualOne to the user. The virutalOne node just for building the relationship between treeData and treeXML at beginning. But the side effect of this method, I found, is that the relationship between treeXML and treeData was cut off. And this leads to that when I added new node (by click the 'addNode' button) to the xmlXML, the xmlData was not affected at all !
    So Is there any other way to solve this issue or bind the incoming xml node list to the xmlListCollection which will be used as Tree control's dataProvider ?

    If u want to display the name : value then u can do like this
    <xsl:eval>this.selectSingleNode("name").nodeName</xsl:eval> : <xsl:value-of select="name" />

  • Help required in ALV Tree Control

    Hi All,
    I am using OO ALV tree Control in my Project every thing is working fine.
    in treecontrol  'If we double click on Node I con it displays resultant screen'- its fine for us
    'If we double click on Node Text it is displaying nothing means no Event is triggering.
    my Requirement is tha 'it should work even if we click on Node Text' . Like in standard Applications SE15 .
    Suggest some Methods regarding this. Note All these nodes are Dynamic Nodes comes from Data Base table.
    Thanks in Adv.
    Murthy

    Just check Tcode: DWDM.
    Good no of example programs for oops tree are available there

  • How to avoid multiple selection in ALV tree control?

    Hi,
    Experts,
    I want to avoid multiple selections on Alv tree control after pressing control keyboard button(Ctrl). Even by pressing Ctrl keyword button i want to select only one row of a Alv tree control.i have used cl_salv_tree class for it is there any method to achieve this please pass some code/idea on it.
    Thanks in advance,
    Shabeer ahmed.

    I haven't tried it before but it should help.
    [https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01]

  • Exending SAME ALV tree control to different screens

    Hi Experts,
    I have to extend same  ALV tree control to other different screens:
    For exmaple:
    I have screen 100 in that I have splitter control on Left ( say TREE_LEFT)  which has ALV tree (ref to CL_GUI_ALV_TREE).
    The same Tree I want to show it in Screen 200 with the same reference(TREE_LEFT)  ..I do not want to create another rererence to for the same tree control, as I have to show the same tree display in screen 200 also.
    Please suggest.
    Regards,
    Sathishkumar.V

    Hi Sathish,
    You are passing the Data to the Screen 100,200,..... by using ALV_GRID OO concept.so the screen is not a constant one.
    It is possible to pass the Data (Based on the ALV_TREE user selection) and Modify the Screen dynamically by designing the Fieldcat.
    So use only one screen may it 100 or 200 and then Pass data based on the user selection from the Tree control.
    For Example Go to TCODE WE02 Execute it will appear one ALV Tree, Based on the Idocs in the Left side tree then screen will display the dynamic Data.
    Thanks,
    Kanagaraja .L

  • Drag and Drop between two ALV Tree Controls

    Hello all,
    I have designed a spilt control of two ALV Trees using CL_GUI_ALV_TREE.
    I have a top node as the Sales order Number and the child node as the items belonging to that sales order number.
    Now i need to drag and drop the lines from one sales order to another.
    Also these drag drop can take place between the nodes of the two different trees.
    Can someone provide with a detail example as i need to complete the same urgently.
    Regards,
    Arun

    Once check the Below code For tree to tree drag an drop
    *       CLASS lcl_main DEFINITION
    CLASS lcl_main  DEFINITION.
      PUBLIC SECTION.
    * Types
        TYPES:
                BEGIN OF  t_ekpo,
                  ebeln TYPE ebeln,
                  ebelp TYPE ebelp,
                END OF    t_ekpo.
        TYPES:
                BEGIN OF  t_vbap,
                  vbeln TYPE vbeln,
                  posnr TYPE vbelp,
                END OF    t_vbap.
    * Internal Tables
        DATA:
              i_ekpo        TYPE STANDARD TABLE OF t_ekpo,
              i_ekpo_op     TYPE STANDARD TABLE OF t_ekpo,
              i_vbap        TYPE STANDARD TABLE OF t_vbap,
              i_vbap_op     TYPE STANDARD TABLE OF t_vbap,
              i_fcat_ekpo   TYPE                   lvc_t_fcat,
              i_fcat_vbap   TYPE                   lvc_t_fcat.
    * Work Areas
        DATA:
              wa_ekpo   TYPE t_ekpo,
              wa_ekpo1  TYPE t_ekpo,
              wa_vbap   TYPE t_vbap,
              wa_vbap1  TYPE t_vbap.
    * Data Declarations
        DATA:
              g_ebeln TYPE ebeln,
              g_vbeln TYPE vbeln_va.
        DATA: g_variant          TYPE disvariant,
              g_hierarchy_header TYPE treev_hhdr,
              g_handle_drag      TYPE i,
              g_handle_drop      TYPE i.
    * Class data
        DATA:
              splitter    TYPE REF TO cl_gui_splitter_container,
              container   TYPE REF TO cl_gui_custom_container,
              container_1 TYPE REF TO cl_gui_container,
              container_2 TYPE REF TO cl_gui_container,
              tree1       TYPE REF TO cl_gui_alv_tree,
              tree2       TYPE REF TO cl_gui_alv_tree,
              g_drag      TYPE REF TO cl_dragdrop,
              g_drop      TYPE REF TO cl_dragdrop.
    * Constants
        CONSTANTS:
                  c_30(2) TYPE c VALUE '30'.
    * Methods
        METHODS:
                  get_data,                          " Data Fatch
                  build_display,                     " Display Container
                  display_ekpo,                      " Ekpo table display
                  display_vbap,                      " Vbap table display
                  add_node_ekpo                      " Add node to Ekpo
                    IMPORTING table  TYPE t_ekpo
                              key    TYPE lvc_nkey
                              text   TYPE lvc_value
                              flag   TYPE c
                    CHANGING  i_key  TYPE lvc_nkey,
                  add_node_vbap                      " Add node to vbap
                    IMPORTING table  TYPE t_vbap
                              key    TYPE lvc_nkey
                              text   TYPE lvc_value
                              flag   TYPE c
                    CHANGING  i_key  TYPE lvc_nkey,
                  dnd_behaviour,                     " Drag and drop behavour
                  register_events_ekpo,              " Register Events Ekpo
                  register_events_vbap,              " Register events vbap
                  handle_drag_multiple               " Drag Multiple Values
                     FOR EVENT on_drag_multiple
                     OF cl_gui_alv_tree
                     IMPORTING sender node_key_table fieldname drag_drop_object,
                  handle_drop                        " Drop the values
                     FOR EVENT on_drop
                     OF cl_gui_alv_tree
                     IMPORTING sender node_key drag_drop_object,
                  add_node_drop                      " Add node to Drop Node
                    IMPORTING table  TYPE t_ekpo
                              key    TYPE lvc_nkey
                              text   TYPE lvc_value
                    CHANGING  i_key  TYPE lvc_nkey.
    ENDCLASS.                                        " Lcl_main DEFINITION
    *       CLASS LCL_DRAGOBJ DEFINITION
    * Drag And drop Structure
    CLASS lcl_dragobj DEFINITION INHERITING FROM lcl_main FINAL.
      PUBLIC SECTION.
    * Types
        TYPES: BEGIN OF t_node_info,
                  l_ekpo      TYPE t_ekpo,
                  l_node_text TYPE lvc_value,
                  l_node_key  TYPE lvc_nkey,
               END OF t_node_info.
    * Data
        DATA: i_node_info  TYPE TABLE OF t_node_info,
              wa_node_info TYPE t_node_info.
    ENDCLASS.                                        " LCL_DRAGOBJ DEFINITION
    * Object Declarations
    DATA  obj_main  TYPE REF TO lcl_main.
    * Initialization                                                     *
    INITIALIZATION.
      CREATE OBJECT obj_main.
    * Selection Screen                                                   *
      SELECTION-SCREEN  BEGIN OF BLOCK  block1  WITH FRAME.
      SELECT-OPTIONS:
                      s_ebeln FOR obj_main->g_ebeln,
                      s_vbeln FOR obj_main->g_vbeln MATCHCODE OBJECT  cs_vbeln.
      SELECTION-SCREEN  END OF   BLOCK  block1.
    * Start of Selection                                                 *
    START-OF-SELECTION.
    * Call Screen
      CALL SCREEN 100.
    *       CLASS lcl_main IMPLEMENTATION
    * Local class Implementation
    CLASS lcl_main  IMPLEMENTATION.
    * Get Data                                                           *
      METHOD  get_data.
    * Data from Ekpo
        SELECT  ebeln
                ebelp
          FROM  ekpo
          UP TO 100 ROWS
          INTO  TABLE i_ekpo
         WHERE  ebeln IN  s_ebeln.
    * Data from Vbap
        SELECT  vbeln
                posnr
          FROM  vbap
          UP TO 100 ROWS
          INTO  TABLE i_vbap
         WHERE  vbeln IN  s_vbeln.
      ENDMETHOD.                                     " Get_data
    * Build Display                                                      *
      METHOD  build_display.
    * Create Container
        CREATE OBJECT container
          EXPORTING
            container_name = 'CUST_CONT'.
    * Split the container
        CREATE OBJECT splitter
          EXPORTING
            parent  = container
            rows    = 1
            columns = 2.
        CALL METHOD splitter->get_container
          EXPORTING
            row       = 1
            column    = 1
          RECEIVING
            container = container_1.
        CALL METHOD splitter->get_container
          EXPORTING
            row       = 1
            column    = 2
          RECEIVING
            container = container_2.
    * create tree control
        CREATE OBJECT tree1
          EXPORTING
            parent                      = container_1
            node_selection_mode         = cl_gui_column_tree=>node_sel_mode_multiple
            item_selection              = 'X'
            no_html_header              = 'X'
            no_toolbar                  = 'X'
          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.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
        CREATE OBJECT tree2
          EXPORTING
            parent                      = container_2
            node_selection_mode         = cl_gui_column_tree=>node_sel_mode_multiple
            item_selection              = 'X'
            no_html_header              = 'X'
            no_toolbar                  = 'X'
          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.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
        g_variant-report      = sy-repid.
        g_variant-handle      = space.
        g_variant-log_group   = space.
        g_variant-username    = space.
        g_variant-text        = space.
        g_variant-dependvars  = space.
    * Call method for get data
        CALL METHOD get_data.
    * Drap And Drop behaviour method
        CALL METHOD dnd_behaviour.
    * Display the Ekpo table
        CALL METHOD obj_main->display_ekpo.
    * Diaplay the vbap table
        CALL METHOD obj_main->display_vbap.
        CALL METHOD tree1->frontend_update.
        CALL METHOD tree2->frontend_update.
      ENDMETHOD.                                     " Build_display
    * Display EKPO                                                       *
      METHOD  display_ekpo.
    * Data
        DATA:
              l_key1 TYPE lvc_nkey,
              l_key2 TYPE lvc_nkey,
              l_key3 TYPE lvc_nkey,
              l_node_text TYPE lvc_value.
    * ALV control service modules
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_buffer_active        = 'X'
            i_structure_name       = 'EKPO'
            i_client_never_display = 'X'
            i_bypassing_buffer     = space
          CHANGING
            ct_fieldcat            = i_fcat_ekpo
          EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
        IF sy-subrc EQ 0.
          DELETE i_fcat_ekpo FROM 4.
        ENDIF.                                       " IF sy-subrc EQ 0.
        g_hierarchy_header-heading = 'Purchase Order Details'(001).
        g_hierarchy_header-tooltip = 'Purchase Order'(002).
        g_hierarchy_header-width = c_30.
        g_hierarchy_header-width_pix = ' '.
    * Diaply
        CALL METHOD tree1->set_table_for_first_display
          EXPORTING
            is_hierarchy_header = g_hierarchy_header
            is_variant          = g_variant
          CHANGING
            it_outtab           = obj_main->i_ekpo_op
            it_fieldcatalog     = i_fcat_ekpo.
        LOOP AT i_ekpo  INTO  wa_ekpo1.
          MOVE wa_ekpo1 TO wa_ekpo.
          l_key1  = ''.
          AT NEW  ebeln.
            MOVE wa_ekpo-ebeln  TO l_node_text.
    * Call method for Add Node to Ekpo
            CALL METHOD add_node_ekpo
              EXPORTING
                table = wa_ekpo
                key   = l_key1
                text  = l_node_text
                flag  = space
              CHANGING
                i_key = l_key2.
          ENDAT.
          CLEAR l_node_text.
          MOVE wa_ekpo-ebelp  TO l_node_text.
    * Call method for Add Node to Ekpo
          CALL METHOD add_node_ekpo
            EXPORTING
              table = wa_ekpo
              key   = l_key2
              text  = l_node_text
              flag  = 'X'
            CHANGING
              i_key = l_key3.
        ENDLOOP.                                     " LOOP AT i_ekpo  INTO  wa_ekpo1.
    * Call method For Register events
        CALL METHOD register_events_ekpo.
      ENDMETHOD.                                     " Display_ekpo
    * Display VBAP                                                       *
      METHOD  display_vbap.
    *  Data
        DATA:
           l_key1 TYPE lvc_nkey,
           l_key2 TYPE lvc_nkey,
           l_key3 TYPE lvc_nkey,
           l_node_text TYPE lvc_value.
        REFRESH i_fcat_vbap.
    * ALV control service modules
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_buffer_active        = 'X'
            i_structure_name       = 'VBAP'
            i_client_never_display = 'X'
            i_bypassing_buffer     = space
          CHANGING
            ct_fieldcat            = i_fcat_vbap
          EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
        IF sy-subrc EQ 0.
          DELETE i_fcat_vbap FROM 4.
        ENDIF.                                       " IF sy-subrc EQ 0.
        g_hierarchy_header-heading = 'Sales Order Details'(003).
        g_hierarchy_header-tooltip = 'Sales Order'(004).
        g_hierarchy_header-width = c_30.
        g_hierarchy_header-width_pix = ' '.
    * Display
        CALL METHOD tree2->set_table_for_first_display
          EXPORTING
            is_hierarchy_header = g_hierarchy_header
            is_variant          = g_variant
          CHANGING
            it_outtab           = obj_main->i_vbap_op
            it_fieldcatalog     = i_fcat_vbap.
        LOOP AT i_vbap  INTO  wa_vbap1.
          MOVE wa_vbap1 TO wa_vbap.
          l_key1  = ''.
          AT NEW  vbeln.
            MOVE wa_vbap-vbeln  TO l_node_text.
    * Call method for Add Node to vbap
            CALL METHOD add_node_vbap
              EXPORTING
                table = wa_vbap
                key   = l_key1
                text  = l_node_text
                flag  = 'X'
              CHANGING
                i_key = l_key2.
          ENDAT.
          CLEAR l_node_text.
          MOVE wa_vbap-posnr  TO l_node_text.
    * Call method for Add Node to vbap
          CALL METHOD add_node_vbap
            EXPORTING
              table = wa_vbap
              key   = l_key2
              text  = l_node_text
              flag  = space
            CHANGING
              i_key = l_key3.
        ENDLOOP.                                     " LOOP AT i_vbap  INTO  wa_vbap1.
    * Call method For Register events
        CALL METHOD register_events_vbap.
      ENDMETHOD.                                     " Display_vbap
    * Add Node to Ekko                                                   *
      METHOD  add_node_ekpo.
    * Data
        DATA: l_layout_node TYPE lvc_s_layn.
        IF flag = 'X'.
          l_layout_node-dragdropid = g_handle_drag.
        ENDIF.                                       " IF flag = 'X'.
    *   Add node to tree1
        CALL METHOD tree1->add_node
          EXPORTING
            i_relat_node_key     = key
            i_relationship       = cl_gui_column_tree=>relat_last_child
            is_outtab_line       = table
            i_node_text          = text
            is_node_layout       = l_layout_node
          IMPORTING
            e_new_node_key       = i_key
          EXCEPTIONS
            relat_node_not_found = 1
            node_not_found       = 2
            OTHERS               = 3.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
      ENDMETHOD.                                     " Add_node_ekpo
    * Add Node to Vbap                                                   *
      METHOD  add_node_vbap.
    * Data
        DATA: l_layout_node TYPE lvc_s_layn.
        IF flag = 'X'.
          l_layout_node-dragdropid = g_handle_drop.
        ENDIF.                                       " IF flag = 'X'.
    * Add node for tree2
        CALL METHOD tree2->add_node
          EXPORTING
            i_relat_node_key     = key
            i_relationship       = cl_gui_column_tree=>relat_last_child
            is_outtab_line       = table
            i_node_text          = text
            is_node_layout       = l_layout_node
          IMPORTING
            e_new_node_key       = i_key
          EXCEPTIONS
            relat_node_not_found = 1
            node_not_found       = 2
            OTHERS               = 3.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
      ENDMETHOD.                                     " Add_node_vbap
    * Dnd behaviour                                                      *
      METHOD  dnd_behaviour.
    * Data
        DATA: effect TYPE i,
              l_flavor TYPE c VALUE 'f'.
    * For drag
        CREATE OBJECT g_drag.
        effect = cl_dragdrop=>copy.
        CALL METHOD g_drag->add
          EXPORTING
            flavor         = l_flavor
            dragsrc        = 'X'
            droptarget     = ' '
            effect         = effect
            effect_in_ctrl = effect.
        CALL METHOD g_drag->get_handle
          IMPORTING
            handle = g_handle_drag.
    * For Drop
        CREATE OBJECT g_drop.
        effect = cl_dragdrop=>copy.
        CALL METHOD g_drop->add
          EXPORTING
            flavor         = l_flavor
            dragsrc        = ' '
            droptarget     = 'X'
            effect         = effect
            effect_in_ctrl = effect.
        CALL METHOD g_drop->get_handle
          IMPORTING
            handle = g_handle_drop.
      ENDMETHOD.                                     " Dnd_behaviour
    * register events                                                    *
      METHOD  register_events_ekpo.
    * Data
        DATA: lt_events TYPE cntl_simple_events.
    * Tree events registers ALV Tree
        CALL METHOD tree1->get_registered_events
          IMPORTING
            events = lt_events.
    * Register events on frontend
        CALL METHOD tree1->set_registered_events
          EXPORTING
            events                    = lt_events
          EXCEPTIONS
            cntl_error                = 1
            cntl_system_error         = 2
            illegal_event_combination = 3.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
    * Event Handling
        SET HANDLER obj_main->handle_drag_multiple FOR tree1.
      ENDMETHOD.                                     " Register_events_ekpo
    * register events                                                    *
      METHOD  register_events_vbap.
    * Data
        DATA: lt_events TYPE cntl_simple_events.
    * Tree events registers ALV Tree
        CALL METHOD tree2->get_registered_events
          IMPORTING
            events = lt_events.
    * Register events on frontend
        CALL METHOD tree2->set_registered_events
          EXPORTING
            events                    = lt_events
          EXCEPTIONS
            cntl_error                = 1
            cntl_system_error         = 2
            illegal_event_combination = 3.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
    * Event
        SET HANDLER obj_main->handle_drop FOR tree2.
      ENDMETHOD.                                     " Register_events_vbap
    * Handle drag multiple Values                                        *
      METHOD handle_drag_multiple.
    * Data
        DATA: dataobj       TYPE REF TO lcl_dragobj,
              l_node_key    TYPE lvc_nkey,
              l_ekpo        TYPE t_ekpo,
              l_node_text   TYPE lvc_value,
              l_node_layout TYPE lvc_s_layn.
    * Create and fill dataobject for event ON_DROP.
        CREATE OBJECT dataobj.
    * Loop the Node key Table
        LOOP AT node_key_table INTO l_node_key.
          CALL METHOD sender->get_outtab_line
            EXPORTING
              i_node_key     = l_node_key
            IMPORTING
              e_outtab_line  = l_ekpo
              e_node_text    = l_node_text
              es_node_layout = l_node_layout.
          IF l_node_layout-isfolder NE 'X'.
            dataobj->wa_node_info-l_node_key  = l_node_key.
            dataobj->wa_node_info-l_ekpo      = l_ekpo.
            dataobj->wa_node_info-l_node_text = l_node_text.
            APPEND dataobj->wa_node_info TO dataobj->i_node_info.
          ENDIF.                                     " IF l_node_layout-isfolder NE 'X'.
        ENDLOOP.                                     " LOOP AT node_key_table INTO l_node_key
        drag_drop_object->object = dataobj.
      ENDMETHOD.                                     " Handle_drag_multiple
    * Handle drop multiple Values                                        *
      METHOD handle_drop.
        DATA: dataobj TYPE REF TO lcl_dragobj,
              l_new_key TYPE lvc_nkey,
              l_node_text TYPE lvc_value.
        CATCH SYSTEM-EXCEPTIONS move_cast_error = 1.
    * ON_DROP
          dataobj ?= drag_drop_object->object.
          LOOP AT dataobj->i_node_info INTO dataobj->wa_node_info.
            MOVE dataobj->wa_node_info-l_node_text  TO l_node_text.
    * Call method for Add Node to vbap
            CALL METHOD add_node_drop
              EXPORTING
                table = dataobj->wa_node_info-l_ekpo
                key   = node_key
                text  = l_node_text
              CHANGING
                i_key = l_new_key.
          ENDLOOP.                                   " LOOP AT dataobj->i_node_info INTO dataobj->wa_node_inf
    * Expand the node
          CALL METHOD sender->expand_node
            EXPORTING
              i_node_key = node_key
          CALL METHOD sender->frontend_update.
        ENDCATCH.
        IF sy-subrc NE 0.
          CALL METHOD drag_drop_object->abort.
        ENDIF.                                       " IF sy-subrc NE 0
      ENDMETHOD.                                     " Handle_drop
    * Add Node to drop                                                   *
      METHOD  add_node_drop.
    * Add node to drop tree
        CALL METHOD tree2->add_node
          EXPORTING
            i_relat_node_key     = key
            i_relationship       = cl_gui_column_tree=>relat_last_child
            is_outtab_line       = table
            i_node_text          = text
    *       is_node_layout       = l_layout_node
          IMPORTING
            e_new_node_key       = i_key
          EXCEPTIONS
            relat_node_not_found = 1
            node_not_found       = 2
            OTHERS               = 3.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0
      ENDMETHOD.                                     " Add_node_drop
    ENDCLASS.                                        " lcl_main IMPLEMENTATION
    *&      Module  STATUS_0100  OUTPUT
    *  Screen 100 Pbo
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'BACK'.
    *  SET TITLEBAR 'xxx'.
      CALL METHOD obj_main->build_display.
    ENDMODULE.                                       " Status_0100 OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *  Screen 100 Pai
    MODULE user_command_0100 INPUT.
      IF sy-ucomm EQ 'BACK'.
        LEAVE TO SCREEN 0.
      ENDIF.                                         " IF sy-ucomm EQ 'BACK'
    ENDMODULE.                                       " USER_COMMAND_0100  INPUT
    *& Report  ZBPS_TREE_DRAG_DROP
    REPORT  zbps_tree_drag_drop.
    *       CLASS lcl_main DEFINITION
    CLASS lcl_main  DEFINITION.
      PUBLIC SECTION.
    * Types
        TYPES:
                BEGIN OF  t_ekpo,
                  ebeln TYPE ebeln,
                  ebelp TYPE ebelp,
                END OF    t_ekpo.
        TYPES:
                BEGIN OF  t_vbap,
                  vbeln TYPE vbeln,
                  posnr TYPE vbelp,
                END OF    t_vbap.
    * Internal Tables
        DATA:
              i_ekpo        TYPE STANDARD TABLE OF t_ekpo,
              i_ekpo_op     TYPE STANDARD TABLE OF t_ekpo,
              i_vbap        TYPE STANDARD TABLE OF t_vbap,
              i_vbap_op     TYPE STANDARD TABLE OF t_vbap,
              i_fcat_ekpo   TYPE                   lvc_t_fcat,
              i_fcat_vbap   TYPE                   lvc_t_fcat.
    * Work Areas
        DATA:
              wa_ekpo   TYPE t_ekpo,
              wa_ekpo1  TYPE t_ekpo,
              wa_vbap   TYPE t_vbap,
              wa_vbap1  TYPE t_vbap.
    * Data Declarations
        DATA:
              g_ebeln TYPE ebeln,
              g_vbeln TYPE vbeln_va.
        DATA: g_variant          TYPE disvariant,
              g_hierarchy_header TYPE treev_hhdr,
              g_handle_drag      TYPE i,
              g_handle_drop      TYPE i.
    * Class data
        DATA:
              splitter    TYPE REF TO cl_gui_splitter_container,
              container   TYPE REF TO cl_gui_custom_container,
              container_1 TYPE REF TO cl_gui_container,
              container_2 TYPE REF TO cl_gui_container,
              tree1       TYPE REF TO cl_gui_alv_tree,
              tree2       TYPE REF TO cl_gui_alv_tree,
              g_drag      TYPE REF TO cl_dragdrop,
              g_drop      TYPE REF TO cl_dragdrop.
    * Constants
        CONSTANTS:
                  c_30(2) TYPE c VALUE '30'.
    * Methods
        METHODS:
                  get_data,                          " Data Fatch
                  build_display,                     " Display Container
                  display_ekpo,                      " Ekpo table display
                  display_vbap,                      " Vbap table display
                  add_node_ekpo                      " Add node to Ekpo
                    IMPORTING table  TYPE t_ekpo
                              key    TYPE lvc_nkey
                              text   TYPE lvc_value
                              flag   TYPE c
                    CHANGING  i_key  TYPE lvc_nkey,
                  add_node_vbap                      " Add node to vbap
                    IMPORTING table  TYPE t_vbap
                              key    TYPE lvc_nkey
                              text   TYPE lvc_value
                              flag   TYPE c
                    CHANGING  i_key  TYPE lvc_nkey,
                  dnd_behaviour,                     " Drag and drop behavour
                  register_events_ekpo,              " Register Events Ekpo
                  register_events_vbap,              " Register events vbap
                  handle_drag_multiple               " Drag Multiple Values
                     FOR EVENT on_drag_multiple
                     OF cl_gui_alv_tree
                     IMPORTING sender node_key_table fieldname drag_drop_object,
                  handle_drop                        " Drop the values
                     FOR EVENT on_drop
                     OF cl_gui_alv_tree
                     IMPORTING sender node_key drag_drop_object,
                  add_node_drop                      " Add node to Drop Node
                    IMPORTING table  TYPE t_ekpo
                              key    TYPE lvc_nkey
                              text   TYPE lvc_value
                    CHANGING  i_key  TYPE lvc_nkey.
    ENDCLASS.                                        " Lcl_main DEFINITION
    *       CLASS LCL_DRAGOBJ DEFINITION
    * Drag And drop Structure
    CLASS lcl_dragobj DEFINITION INHERITING FROM lcl_main FINAL.
      PUBLIC SECTION.
    * Types
        TYPES: BEGIN OF t_node_info,
                  l_ekpo      TYPE t_ekpo,
                  l_node_text TYPE lvc_value,
                  l_node_key  TYPE lvc_nkey,
               END OF t_node_info.
    * Data
        DATA: i_node_info  TYPE TABLE OF t_node_info,
              wa_node_info TYPE t_node_info.
    ENDCLASS.                                        " LCL_DRAGOBJ DEFINITION
    * Object Declarations
    DATA  obj_main  TYPE REF TO lcl_main.
    * Initialization                                                     *
    INITIALIZATION.
      CREATE OBJECT obj_main.
    * Selection Screen                                                   *
      SELECTION-SCREEN  BEGIN OF BLOCK  block1  WITH FRAME.
      SELECT-OPTIONS:
                      s_ebeln FOR obj_main->g_ebeln,
                      s_vbeln FOR obj_main->g_vbeln MATCHCODE OBJECT  cs_vbeln.
      SELECTION-SCREEN  END OF   BLOCK  block1.
    * Start of Selection                                                 *
    START-OF-SELECTION.
    * Call Screen
      CALL SCREEN 100.
    *       CLASS lcl_main IMPLEMENTATION
    * Local class Implementation
    CLASS lcl_main  IMPLEMENTATION.
    * Get Data                                                           *
      METHOD  get_data.
    * Data from Ekpo
        SELECT  ebeln
                ebelp
          FROM  ekpo
          UP TO 100 ROWS
          INTO  TABLE i_ekpo
         WHERE  ebeln IN  s_ebeln.
    * Data from Vbap
        SELECT  vbeln
                posnr
          FROM  vbap
          UP TO 100 ROWS
          INTO  TABLE i_vbap
         WHERE  vbeln IN  s_vbeln.
      ENDMETHOD.                                     " Get_data
    * Build Display                                                      *
      METHOD  build_display.
    * Create Container
        CREATE OBJECT container
          EXPORTING
            container_name = 'CUST_CONT'.
    * Split the container
        CREATE OBJECT splitter
          EXPORTING
            parent  = container
            rows    = 1
            columns = 2.
        CALL METHOD splitter->get_container
          EXPORTING
            row       = 1
            column    = 1
          RECEIVING
            container = container_1.
        CALL METHOD splitter->get_container
          EXPORTING
            row       = 1
            column    = 2
          RECEIVING
            container = container_2.
    * create tree control
        CREATE OBJECT tree1
          EXPORTING
            parent                      = container_1
            node_selection_mode         = cl_gui_column_tree=>node_sel_mode_multiple
            item_selection              = 'X'
            no_html_header              = 'X'
            no_toolbar                  = 'X'
          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.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
        CREATE OBJECT tree2
          EXPORTING
            parent                      = container_2
            node_selection_mode         = cl_gui_column_tree=>node_sel_mode_multiple
            item_selection              = 'X'
            no_html_header              = 'X'
            no_toolbar                  = 'X'
          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.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
        g_variant-report      = sy-repid.
        g_variant-handle      = space.
        g_variant-log_group   = space.
        g_variant-username    = space.
        g_variant-text        = space.
        g_variant-dependvars  = space.
    * Call method for get data
        CALL METHOD get_data.
    * Drap And Drop behaviour method
        CALL METHOD dnd_behaviour.
    * Display the Ekpo table
        CALL METHOD obj_main->display_ekpo.
    * Diaplay the vbap table
        CALL METHOD obj_main->display_vbap.
        CALL METHOD tree1->frontend_update.
        CALL METHOD tree2->frontend_update.
      ENDMETHOD.                                     " Build_display
    * Display EKPO                                                       *
      METHOD  display_ekpo.
    * Data
        DATA:
              l_key1 TYPE lvc_nkey,
              l_key2 TYPE lvc_nkey,
              l_key3 TYPE lvc_nkey,
              l_node_text TYPE lvc_value.
    * ALV control service modules
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_buffer_active        = 'X'
            i_structure_name       = 'EKPO'
            i_client_never_display = 'X'
            i_bypassing_buffer     = space
          CHANGING
            ct_fieldcat            = i_fcat_ekpo
          EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
        IF sy-subrc EQ 0.
          DELETE i_fcat_ekpo FROM 4.
        ENDIF.                                       " IF sy-subrc EQ 0.
        g_hierarchy_header-heading = 'Purchase Order Details'(001).
        g_hierarchy_header-tooltip = 'Purchase Order'(002).
        g_hierarchy_header-width = c_30.
        g_hierarchy_header-width_pix = ' '.
    * Diaply
        CALL METHOD tree1->set_table_for_first_display
          EXPORTING
            is_hierarchy_header = g_hierarchy_header
            is_variant          = g_variant
          CHANGING
            it_outtab           = obj_main->i_ekpo_op
            it_fieldcatalog     = i_fcat_ekpo.
        LOOP AT i_ekpo  INTO  wa_ekpo1.
          MOVE wa_ekpo1 TO wa_ekpo.
          l_key1  = ''.
          AT NEW  ebeln.
            MOVE wa_ekpo-ebeln  TO l_node_text.
    * Call method for Add Node to Ekpo
            CALL METHOD add_node_ekpo
              EXPORTING
                table = wa_ekpo
                key   = l_key1
                text  = l_node_text
                flag  = space
              CHANGING
                i_key = l_key2.
          ENDAT.
          CLEAR l_node_text.
          MOVE wa_ekpo-ebelp  TO l_node_text.
    * Call method for Add Node to Ekpo
          CALL METHOD add_node_ekpo
            EXPORTING
              table = wa_ekpo
              key   = l_key2
              text  = l_node_text
              flag  = 'X'
            CHANGING
              i_key = l_key3.
        ENDLOOP.                                     " LOOP AT i_ekpo  INTO  wa_ekpo1.
    * Call method For Register events
        CALL METHOD register_events_ekpo.
      ENDMETHOD.                                     " Display_ekpo
    * Display VBAP                                                       *
      METHOD  display_vbap.
    *  Data
        DATA:
           l_key1 TYPE lvc_nkey,
           l_key2 TYPE lvc_nkey,
           l_key3 TYPE lvc_nkey,
           l_node_text TYPE lvc_value.
        REFRESH i_fcat_vbap.
    * ALV control service modules
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_buffer_active        = 'X'
            i_structure_name       = 'VBAP'
            i_client_never_display = 'X'
            i_bypassing_buffer     = space
          CHANGING
            ct_fieldcat            = i_fcat_vbap
          EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
        IF sy-subrc EQ 0.
          DELETE i_fcat_vbap FROM 4.
        ENDIF.                                       " IF sy-subrc EQ 0.
        g_hierarchy_header-heading = 'Sales Order Details'(003).
        g_hierarchy_header-tooltip = 'Sales Order'(004).
        g_hierarchy_header-width = c_30.
        g_hierarchy_header-width_pix = ' '.
    * Display
        CALL METHOD tree2->set_table_for_first_display
          EXPORTING
            is_hierarchy_header = g_hierarchy_header
            is_variant          = g_variant
          CHANGING
            it_outtab           = obj_main->i_vbap_op
            it_fieldcatalog     = i_fcat_vbap.
        LOOP AT i_vbap  INTO  wa_vbap1.
          MOVE wa_vbap1 TO wa_vbap.
          l_key1  = ''.
          AT NEW  vbeln.
            MOVE wa_vbap-vbeln  TO l_node_text.
    * Call method for Add Node to vbap
            CALL METHOD add_node_vbap
              EXPORTING
                table = wa_vbap
                key   = l_key1
                text  = l_node_text
                flag  = 'X'
              CHANGING
                i_key = l_key2.
          ENDAT.
          CLEAR l_node_text.
          MOVE wa_vbap-posnr  TO l_node_text.
    * Call method for Add Node to vbap
          CALL METHOD add_node_vbap
            EXPORTING
              table = wa_vbap
              key   = l_key2
              text  = l_node_text
              flag  = space
            CHANGING
              i_key = l_key3.
        ENDLOOP.                                     " LOOP AT i_vbap  INTO  wa_vbap1.
    * Call method For Register events
        CALL METHOD register_events_vbap.
      ENDMETHOD.                                     " Display_vbap
    * Add Node to Ekko                                                   *
      METHOD  add_node_ekpo.
    * Data
        DATA: l_layout_node TYPE lvc_s_layn.
        IF flag = 'X'.
          l_layout_node-dragdropid = g_handle_drag.
        ENDIF.                                       " IF flag = 'X'.
    *   Add node to tree1
        CALL METHOD tree1->add_node
          EXPORTING
            i_relat_node_key     = key
            i_relationship       = cl_gui_column_tree=>relat_last_child
            is_outtab_line       = table
            i_node_text          = text
            is_node_layout       = l_layout_node
          IMPORTING
            e_new_node_key       = i_key
          EXCEPTIONS
            relat_node_not_found = 1
            node_not_found       = 2
            OTHERS               = 3.
        IF sy-subrc NE 0.
          CLEAR sy-subrc.
        ENDIF.                                       " IF sy-subrc NE 0.
      ENDMETHOD.                                     " Add_node_ekpo
    * Add Node to Vbap                                                   *
      METHOD  add_node_vbap.
    * Data
        DATA: l_layout_node TYPE lvc_s_layn.
        IF flag = 'X'.
          l_layout_node-dragdropid = g_handle_drop.
        ENDIF.                                       " IF flag = 'X'.
    * Add node for tree2
        CALL METHOD t

  • Editable Field in ALV Tree Control

    Hello All,
    Can anyone tell me how can i make a field editable in an Alv Tree grid. I have tried with fiedcatalog-edit = 'X'. but that doesn't work. 
    also please provide a piece of code to be clear ...
    Thanks,
    Ravi Aswani

    hI ,
    Data : LI_fieldcat  type lvc_t_fcat,
              ls_fcat type lvc_s_fcat.
    IF OKCODE = 'MAIN'.
          CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
        I_BUFFER_ACTIVE              =
          i_structure_name             = 'ZCUS'
        I_CLIENT_NEVER_DISPLAY       = 'X'
        I_BYPASSING_BUFFER           =
        I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = LI_fieldcat[]            .
      LOOP AT LI_FIELDCAT INTO LS_FCAT.
        CASE ls_fcat-fieldname.
          WHEN 'KUNNR'.
            ls_fcat-col_pos = 1.
          WHEN 'NAME1'.
            ls_fcat-edit = 'X'.
            ls_fcat-col_pos = 2.
          WHEN 'ORT01'.
            ls_fcat-edit = 'X'.
            ls_fcat-col_pos = 3.
            ls_fcat-drdn_hndl = '1'.
            ls_fcat-outputlen = 20.
          WHEN 'LAND1'.
            ls_fcat-edit = 'X'.
            ls_fcat-col_pos = 4.
        ENDCASE.
        MODIFY LI_fieldcat FROM ls_fcat.
      ENDLOOP.
    ENDIF.
    With this The internal Table contains 4 fields Kunnr Name1 Ort01 Land1 Here Kunnr is the Key field so , it is not editable , reaming fields are Editable.
    There u must write the Modify statement.
    check it once
    Regards
    Krishna

  • Check box Handling in ALV Tree Control

    Hi All,
    I am implementing a scenario wherein which I need to get the checked items and process upon the user action. In the implementation I am not getting the checked values.
    This is how I have implemented.
    I have added a check box field in the Field catalog which is type c
    * Item Layout for the Check box.
      lwa_item_layout-fieldname = 'CHKBOX'.
      lwa_item_layout-class   = cl_gui_column_tree=>item_class_checkbox.
      lwa_item_layout-editable = 'X'.
      APPEND lwa_item_layout TO lt_item_layout.
    After that I have tried to used this code to get the checked items.
       CALL METHOD tree1->get_checked_items
              IMPORTING
                et_checked_items = t_checked.
    But I am not getting any values in the table.
    Further I have tried to use the Event  <b>checkbox_change</b> for the check box logic( I am not sure but I thought it is)
    But the event is not triggering with this... Please Help me in this regard...

    CLASS cl_toolbar_event_receiver DEFINITION.
        PUBLIC SECTION.
    *      DATA: checked TYPE c,
    *            fieldname TYPE lvc_fname,
    *            node_key TYPE lvc_nkey.
          METHODS: on_function_selected
                     FOR EVENT function_selected OF cl_gui_toolbar
                       IMPORTING fcode.
          METHODS: handle_check_box_change
          FOR EVENT checkbox_change OF cl_gui_alv_tree
          IMPORTING checked
                    fieldname
                    node_key.
      ENDCLASS
    Does this Implementation giving any problem for this?

  • Financial statement version list output

    Hi all,
    I would like to set as default the list output: ALV grid control in trasaction code S_ALR_87012284 in version 6.0 Is there anyway to do it? Everytime we enter to this report we have to change the list output from classical list to ALV grid control.
    Thanks!

    One way is to create a transaction variant using SHD0 that will default the ALV grid control. See the following thread for more info.
    Documentation about t-code SHD0

  • Report with ALV tree and ALV list?

    I need to create a report with layout as same as this one
    [http://trangiegie.com/MyFile/output.JPG]
    It looks like a report with combination of ALV tree and list. The tree works like a navigation bar. Wonder if there are any demo programs like this. Will appreciate any help.

    For Tree alone - You can check program : BCALV_TREE_02
    Program Name                   Report title
    BCALV_GRID_DND_TREE            ALV Grid: Drag and Drop with ALV Tree
    BCALV_GRID_DND_TREE_SIMPLE     ALV GRID: Drag and drop with ALV tree (simple)
    BCALV_TEST_COLUMN_TREE         Program BCALV_TEST_COLUMN_TREE
    BCALV_TEST_SIMPLE_TREE         Program BCALV_TEST_SIMPLE_TREE
    BCALV_TREE_01                  ALV Tree Control: Build Up the Hierarchy Tree
    BCALV_TREE_02                  ALV Tree Control: Event Handling
    BCALV_TREE_03                  ALV Tree Control: Use an Own Context Menu
    BCALV_TREE_04                  ALV Tree Control: Add a Button to the Toolbar
    BCALV_TREE_05                  ALV Tree Control: Add a Menu to the Toolbar
    BCALV_TREE_06                  ALV tree control: Icon column and icon for nodes/items
    BCALV_TREE_DEMO                Demo for ALV tree control
    BCALV_TREE_DND                 ALV tree control: Drag & Drop within a hierarchy tree
    BCALV_TREE_DND_MULTIPLE        ALV tree control: Drag & Drop within a hierarchy tree
    BCALV_TREE_EVENT_RECEIVER      Include BCALV_TREE_EVENT_RECEIVER
    BCALV_TREE_EVENT_RECEIVER01
    BCALV_TREE_ITEMLAYOUT          ALV Tree: Change Item Layouts at Runtime
    BCALV_TREE_MOVE_NODE_TEST      Demo for ALV tree control
    BCALV_TREE_SIMPLE_DEMO         Program BCALV_TREE_SIMPLE_DEMO
    BCALV_TREE_VERIFY              Verifier for ALV Tree and Simple ALV Tree

  • ALV Tree using ABAP Objects

    Can anyone tell me how to Copy a node on an ALV Tree using context menu ?

    Hello Vidya
    The sample report ZUS_SDN_ALVTREE_CTXMENU demonstrates how to copy nodes on an ALV tree.
    Before showing the entire coding I would like to point out a few crucial parts of the coding:
    (1) Defintion of OUTTAB list
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE  TYPE vbak.
    TYPES: nkey     TYPE lvc_nkey.
    TYPES: ntype    TYPE lvc_value.  " 'VKORG' / 'VTWEG' / 'SPART' / leaf
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    The OUTTAB list contains two additional fields holding the tree key (LVC_NKEY) and the node type.
    (2) The main logic of the report is implemented in event handler method handle_node_ctxmenu_sel.
          WHEN 'COPY_SUBTREE'.
            CALL METHOD go_alvtree->get_subtree
              EXPORTING
                i_node_key       = node_key
              IMPORTING
                et_subtree_nodes = lt_subtree.
            CALL METHOD go_alvtree->get_parent
              EXPORTING
                i_node_key        = node_key
              IMPORTING
                e_parent_node_key = ld_parent_key.
            LOOP AT lt_subtree INTO ld_node_key.
              READ TABLE gt_outtab INTO ls_outtab
                   WITH KEY nkey = ld_node_key.
              APPEND ls_outtab TO lt_outtab.
            ENDLOOP.
            READ TABLE lt_outtab INTO ls_outtab INDEX 1.
            ld_ntype = ls_outtab-ntype.
            DELETE lt_outtab WHERE ( vbeln IS INITIAL ).  " hierarchy nodes
            CASE ld_ntype.
              WHEN 'VKORG'.
                ld_top_key = ld_parent_key.
              WHEN 'VTWEG'.
                ld_vkorg_key = ld_parent_key.
              WHEN 'SPART'.
                ld_vtweg_key = ld_parent_key.
              WHEN 'LEAF'.
                ld_spart_key = ld_parent_key.
            ENDCASE.
    "       Note: similar logic like in routine CREATE_HIERARCHY
            SORT lt_outtab BY vkorg vtweg spart kunnr audat.
            LOOP AT lt_outtab INTO ls_outtab.
    *& Report  ZUS_SDN_ALVTREE_CTXMENU
    *& Based on: BCALV_TREE_03
    REPORT  zus_sdn_alvtree_ctxmenu.
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE  TYPE vbak.
    TYPES: nkey     TYPE lvc_nkey.
    TYPES: ntype    TYPE lvc_value.  " 'VKORG' / 'VTWEG' / 'SPART' / leaf
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA:
      gd_repid      TYPE syst-repid,
      gd_okcode     TYPE ui_func,
      go_docking    TYPE REF TO cl_gui_docking_container,
      go_alvtree    TYPE REF TO cl_gui_alv_tree.
    DATA:
      gt_outtab     TYPE ty_t_outtab,  " Sales Document
      gt_fcat       TYPE lvc_t_fcat.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
    * §2. Define an event handler method to build up a context menu
    *     (postfix of event name: _CONTEXT_MENU_REQUEST).
    * This event is fired each time the user klick with the right
    * mouse button on a node.
        CLASS-METHODS:
          handle_node_ctxmenu_req
          FOR EVENT node_context_menu_request OF cl_gui_alv_tree
            IMPORTING
              node_key
              menu,
    * §3. Define an event handler method to respond to a function code
    *     triggered by your menu (postfix: _CONTEXT_MENU_SELECTED).
    * This event is fired when the user selects an entry of the
    * build up context menu.
          handle_node_ctxmenu_sel
          FOR EVENT node_context_menu_selected OF cl_gui_alv_tree
            IMPORTING
              node_key
              fcode
              sender.
    * 'sender' is an implicit event parameter that is provided by
    * ABAP Objects runtime system. It contains a reference to the
    * object that fired the event. You may directly use it to
    * call methods of this instance.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
    * §4. Implement your event handler methods.
      METHOD handle_node_ctxmenu_req.
    * Event parameter 'menu' holds a reference to the standard context
    * menu of ALV Tree (functions 'Expand'/'Collapse' on nodes).
    * You may either append your own functions (separated by a line)
    * or clear the menu if you do not want to allow standard functions.
    * In this case the standard menu is cleared.
        CALL METHOD menu->clear.
    * The next line defines one line of the context menu.
        CALL METHOD menu->add_function
          EXPORTING
            fcode = 'DEL_SUBTREE'
            text  = 'Delete Subtree'(901).        "Delete Subtree
        CALL METHOD menu->add_function
          EXPORTING
            fcode = 'COPY_SUBTREE'
            text  = 'Copy Subtree'(902).        "Copy Subtree
      ENDMETHOD.                    "handle_node_ctxmenu_req
      METHOD handle_node_ctxmenu_sel.
    * At this point of execution, the user selected a menu entry of the
    * menu build up in event handler method handle_node_cm_req.
    * Query your own function codes and react accordingly.
        DATA:
          l_rc TYPE c,
          ld_ntype      TYPE lvc_value,
          ld_parent_key TYPE lvc_nkey,
          ld_node_key   TYPE lvc_nkey,
          lt_subtree    TYPE lvc_t_nkey,
          ls_outtab     TYPE ty_s_outtab,
          ls_last       TYPE ty_s_outtab,
          lt_outtab     TYPE ty_t_outtab.
        DATA:
          ld_vkorg_key   TYPE lvc_nkey,
          ld_vtweg_key   TYPE lvc_nkey,
          ld_spart_key   TYPE lvc_nkey,
          ld_last_key    TYPE lvc_nkey,
          ld_top_key     TYPE lvc_nkey.
        CASE fcode.
          WHEN 'DEL_SUBTREE'.
            CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
                 EXPORTING
                      textline1      = 'Do you really want to delete'(902)
                    textline2      = 'this node and all its subnodes?'(903)
                      titel          = 'Confirmation'(904)
                      cancel_display = ' '
                 IMPORTING
                      answer         = l_rc.
            IF l_rc EQ 'J'.
              CALL METHOD sender->delete_subtree
                EXPORTING
                  i_node_key = node_key.
    * Do not forget to refresh the display when you change the contents
    * of your list.
              CALL METHOD sender->frontend_update.
            ENDIF.
          WHEN 'COPY_SUBTREE'.
            CALL METHOD go_alvtree->get_subtree
              EXPORTING
                i_node_key       = node_key
              IMPORTING
                et_subtree_nodes = lt_subtree.
            CALL METHOD go_alvtree->get_parent
              EXPORTING
                i_node_key        = node_key
              IMPORTING
                e_parent_node_key = ld_parent_key.
            LOOP AT lt_subtree INTO ld_node_key.
              READ TABLE gt_outtab INTO ls_outtab
                   WITH KEY nkey = ld_node_key.
              APPEND ls_outtab TO lt_outtab.
            ENDLOOP.
            READ TABLE lt_outtab INTO ls_outtab INDEX 1.
            ld_ntype = ls_outtab-ntype.
            DELETE lt_outtab WHERE ( vbeln IS INITIAL ).  " hierarchy nodes
            CASE ld_ntype.
              WHEN 'VKORG'.
                ld_top_key = ld_parent_key.
              WHEN 'VTWEG'.
                ld_vkorg_key = ld_parent_key.
              WHEN 'SPART'.
                ld_vtweg_key = ld_parent_key.
              WHEN 'LEAF'.
                ld_spart_key = ld_parent_key.
            ENDCASE.
            SORT lt_outtab BY vkorg vtweg spart kunnr audat.
            LOOP AT lt_outtab INTO ls_outtab.
              IF ( ld_ntype = 'VKORG' ).
                "   new sales organisation
                IF ( ls_outtab-vkorg = ls_last-vkorg ).
                ELSE.
                  PERFORM add_sales_org
                                    USING
                                       ls_outtab
                                       ld_top_key
                                 CHANGING
                                       ld_vkorg_key.
                  ls_outtab-nkey   = ld_vkorg_key.
                  ls_outtab-ntype = 'VKORG'.
                  DESCRIBE TABLE gt_outtab.  " fill sy-tfill
                  MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
                    TRANSPORTING nkey ntype.
                ENDIF.
              ENDIF.
              IF ( ld_ntype = 'VKORG'  OR
                   ld_ntype = 'VTWEG' ).
                "   new distribution channel
                IF ( ls_outtab-vkorg = ls_last-vkorg  AND
                     ls_outtab-vtweg = ls_last-vtweg ).
                ELSE.
                  PERFORM add_distrib_chan
                                    USING
                                       ls_outtab
                                       ld_vkorg_key
                                 CHANGING
                                       ld_vtweg_key.
                  ls_outtab-nkey = ld_vtweg_key.
                  ls_outtab-ntype = 'VTWEG'.
                  DESCRIBE TABLE gt_outtab.  " fill sy-tfill
                  MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
                    TRANSPORTING nkey ntype.
                ENDIF.
              ENDIF.
              IF ( ld_ntype = 'VKORG'  OR
                   ld_ntype = 'VTWEG'  OR
                   ld_ntype = 'SPART' ).
                "   new channel
                IF ( ls_outtab-vkorg = ls_last-vkorg  AND
                     ls_outtab-vtweg = ls_last-vtweg  AND
                     ls_outtab-spart = ls_last-spart ).
                ELSE.
                  PERFORM add_division
                                    USING
                                       ls_outtab
                                       ld_vtweg_key
                                 CHANGING
                                       ld_spart_key.
                  ls_outtab-nkey = ld_spart_key.
                  ls_outtab-ntype = 'SPART'.
                  DESCRIBE TABLE gt_outtab.  " fill sy-tfill
                  MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
                    TRANSPORTING nkey ntype.
                ENDIF.
              ENDIF.
    * Leaf:
              PERFORM add_complete_line
                                USING
                                   ls_outtab
                                   ld_spart_key
                             CHANGING
                                   ld_last_key.
              ls_outtab-nkey = ld_last_key.
              ls_outtab-ntype = 'LEAF'.
              DESCRIBE TABLE gt_outtab.  " fill sy-tfill
              MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
                  TRANSPORTING nkey ntype.
              ls_last = ls_outtab.
            ENDLOOP.
            CALL METHOD cl_gui_cfw=>set_new_ok_code
              EXPORTING
                new_code = 'REFRESH_TREE'
    *          IMPORTING
    *            RC       =
        ENDCASE.
      ENDMETHOD.                    "handle_node_ctxmenu_sel
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      PERFORM init_controls.
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL SCREEN '0100'.
    * NOTE: no screen elements, ok_code -> gd_okcode
    **    PROCESS BEFORE OUTPUT.
    **      MODULE STATUS_0100.
    **    PROCESS AFTER INPUT.
    **      MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      TRANSLATE gd_okcode TO UPPER CASE.  " facilitate manual entries
      CASE gd_okcode.
        WHEN 'BACK' OR
             'EXIT'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
      when 'REFRESH_TREE'.
        CALL METHOD go_alvtree->update_calculations
    *      EXPORTING
    *        NO_FRONTEND_UPDATE =
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
      DATA:
        ls_hierarchy_header TYPE treev_hhdr.
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_docking->set_extension
        EXPORTING
          extension  = 99999 " full-size screen
        EXCEPTIONS
          cntl_error = 1
          OTHERS     = 2.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * create tree control
      CREATE OBJECT go_alvtree
        EXPORTING
            parent              = go_docking
            node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
            item_selection      = ' '
            no_html_header      = 'X'
            no_toolbar          = ''
        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.
      IF sy-subrc <> 0.
        MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
      ENDIF.
      PERFORM build_hierarchy_header CHANGING ls_hierarchy_header.
    * Hide columns and sum up values initially using the fieldcatalog
      PERFORM build_fieldcatalog.
    * IMPORTANT: Table 'gt_sflight' must be empty. Do not change this table
    * (even after this method call). You can change data of your table
    * by calling methods of CL_GUI_ALV_TREE.
    * Furthermore, the output table 'gt_outtab' must be global and can
    * only be used for one ALV Tree Control.
      CALL METHOD go_alvtree->set_table_for_first_display
        EXPORTING
          is_hierarchy_header = ls_hierarchy_header
        CHANGING
          it_fieldcatalog     = gt_fcat
          it_outtab           = gt_outtab. "table must be empty !
      PERFORM init_tree.
    ENDFORM.                    " INIT_CONTROLS
    *&      Form  INIT_TREE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_tree .
      PERFORM create_hierarchy.
      PERFORM register_events.
    * Update calculations which were initially defined by field DO_SUM
    * of the fieldcatalog. (see build_fieldcatalog).
      CALL METHOD go_alvtree->update_calculations.
    * Send data to frontend.
      CALL METHOD go_alvtree->frontend_update.
    ENDFORM.                    " INIT_TREE
    *&      Form  build_hierarchy_header
    *       text
    *      <--P_LS_HIERARCHY_HEADER  text
    FORM build_hierarchy_header
         CHANGING
               cs_hierarchy_header TYPE treev_hhdr.
      cs_hierarchy_header-heading =
            'SalesOrg/DistChannel/Division'(300).
      cs_hierarchy_header-tooltip = 'Customer: Master Sales Data'(400).
      cs_hierarchy_header-width = 45.
      cs_hierarchy_header-width_pix = ''.
    ENDFORM.                    " build_hierarchy_header
    *&      Form  build_fieldcatalog
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog .
    * define local data
      DATA:
        ls_fcat    TYPE lvc_s_fcat.
      REFRESH: gt_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
         i_structure_name             = 'VBAK'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      LOOP AT gt_fcat INTO ls_fcat.
        CASE ls_fcat-fieldname.
          WHEN 'VBELN'  OR
               'AUDAT'  OR
               'AUART'  OR
               'WAERK'  OR
               'VKORG'  OR
               'VTWEG'  OR
               'SPART'  OR
               'BSTNK'  OR
               'KUNNR'.
          WHEN 'NETWR'.
            ls_fcat-do_sum = 'X'.
            ls_fcat-h_ftype = 'SUM'.  " or: 'MAX' / 'AVG'
          WHEN OTHERS.
            ls_fcat-tech = 'X'.
        ENDCASE.
        MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
      ENDLOOP.
    ENDFORM.                    " build_fieldcatalog
    *&      Form  create_hierarchy
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_hierarchy .
    * define local data
      DATA:
        ls_outtab    TYPE ty_s_outtab,
        ls_last      TYPE ty_s_outtab,
        lt_outtab    TYPE ty_t_outtab.
      DATA:
        ld_vkorg_key   TYPE lvc_nkey,
        ld_vtweg_key   TYPE lvc_nkey,
        ld_spart_key   TYPE lvc_nkey,
        ld_last_key    TYPE lvc_nkey,
        ld_top_key     TYPE lvc_nkey.
      " Select data
      SELECT * FROM  vbak INTO CORRESPONDING FIELDS OF TABLE lt_outtab
        UP TO 1550 ROWS.
      " sort table according to conceived hierarchy
      SORT lt_outtab BY vkorg vtweg spart kunnr audat.
    * Define one top node. In this way it is possible to calculate
    * values for the whole hierarchy.
      CALL METHOD go_alvtree->add_node
        EXPORTING
          i_relat_node_key = ''
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = 'Sales Documents'
        IMPORTING
          e_new_node_key   = ld_top_key.
      CLEAR: ls_outtab.
      ls_outtab-nkey  = ld_top_key.
      ls_outtab-ntype = 'ROOT'.
      MODIFY gt_outtab FROM ls_outtab INDEX 1
            TRANSPORTING nkey ntype.
      LOOP AT lt_outtab INTO ls_outtab.
        "   new sales organisation
        IF ( ls_outtab-vkorg = ls_last-vkorg ).
        ELSE.
          PERFORM add_sales_org
                            USING
                               ls_outtab
                               ld_top_key
                         CHANGING
                               ld_vkorg_key.
          ls_outtab-nkey   = ld_vkorg_key.
          ls_outtab-ntype = 'VKORG'.
          DESCRIBE TABLE gt_outtab.  " fill sy-tfill
          MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
            TRANSPORTING nkey ntype.
        ENDIF.
        "   new distribution channel
        IF ( ls_outtab-vkorg = ls_last-vkorg  AND
             ls_outtab-vtweg = ls_last-vtweg ).
        ELSE.
          PERFORM add_distrib_chan
                            USING
                               ls_outtab
                               ld_vkorg_key
                         CHANGING
                               ld_vtweg_key.
          ls_outtab-nkey = ld_vtweg_key.
          ls_outtab-ntype = 'VTWEG'.
          DESCRIBE TABLE gt_outtab.  " fill sy-tfill
          MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
            TRANSPORTING nkey ntype.
        ENDIF.
        "   new channel
        IF ( ls_outtab-vkorg = ls_last-vkorg  AND
             ls_outtab-vtweg = ls_last-vtweg  AND
             ls_outtab-spart = ls_last-spart ).
        ELSE.
          PERFORM add_division
                            USING
                               ls_outtab
                               ld_vtweg_key
                         CHANGING
                               ld_spart_key.
          ls_outtab-nkey = ld_spart_key.
          ls_outtab-ntype = 'SPART'.
          DESCRIBE TABLE gt_outtab.  " fill sy-tfill
          MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
            TRANSPORTING nkey ntype.
        ENDIF.
    * Leaf:
        PERFORM add_complete_line
                          USING
                             ls_outtab
                             ld_spart_key
                       CHANGING
                             ld_last_key.
        ls_outtab-nkey = ld_last_key.
        ls_outtab-ntype = 'LEAF'.
        DESCRIBE TABLE gt_outtab.  " fill sy-tfill
        MODIFY gt_outtab FROM ls_outtab INDEX syst-tfill
            TRANSPORTING nkey ntype.
        ls_last = ls_outtab.
      ENDLOOP.
    ENDFORM.                    " create_hierarchy
    *&      Form  ADD_SALES_ORG
    *       text
    *      -->P_LS_OUTTAB  text
    *      -->P_LD_TOP_KEY  text
    *      <--P_LD_VKORG_KEY  text
    FORM add_sales_org
                   USING
                      value(us_outtab)     TYPE ty_s_outtab
                      value(ud_relat_key)  TYPE lvc_nkey
                CHANGING
                      cd_node_key          TYPE lvc_nkey.
    * define local data
      DATA:
       ld_nodetext    TYPE lvc_value,
       ls_outtab      TYPE ty_s_outtab.
      ld_nodetext = us_outtab-vkorg.
      " add node
      CALL METHOD go_alvtree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = ld_nodetext
          is_outtab_line   = ls_outtab
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                    " ADD_SALES_ORG
    *&      Form  add_DISTRIB_CHAN
    *       text
    *      -->P_LS_OUTTAB  text
    *      -->P_LD_VKORG_KEY  text
    *      <--P_LD_VTWEG_KEY  text
    FORM add_distrib_chan
                   USING
                      value(us_outtab)     TYPE ty_s_outtab
                      value(ud_relat_key)  TYPE lvc_nkey
                CHANGING
                      cd_node_key          TYPE lvc_nkey.
    * define local data
      DATA:
       ld_nodetext    TYPE lvc_value,
       ls_outtab      TYPE ty_s_outtab.
      ld_nodetext = us_outtab-vtweg.
      " add node
      CALL METHOD go_alvtree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = ld_nodetext
          is_outtab_line   = ls_outtab
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                    " add_DISTRIB_CHAN
    *&      Form  add_division
    *       text
    *      -->P_LS_OUTTAB  text
    *      -->P_LD_VTWEG_KEY  text
    *      <--P_LD_SPART_KEY  text
    FORM add_division
                   USING
                      value(us_outtab)     TYPE ty_s_outtab
                      value(ud_relat_key)  TYPE lvc_nkey
                CHANGING
                      cd_node_key          TYPE lvc_nkey.
    * define local data
      DATA:
       ld_nodetext    TYPE lvc_value,
       ls_outtab      TYPE ty_s_outtab.
      ld_nodetext = us_outtab-spart.
      " add node
      CALL METHOD go_alvtree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = ld_nodetext
          is_outtab_line   = ls_outtab
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                    " add_division
    *&      Form  add_complete_line
    *       text
    *      -->P_LS_OUTTAB  text
    *      -->P_LD_SPART_KEY  text
    *      <--P_LD_LAST_KEY  text
    FORM add_complete_line
                   USING
                      value(us_outtab)     TYPE ty_s_outtab
                      value(ud_relat_key)  TYPE lvc_nkey
                CHANGING
                      cd_node_key          TYPE lvc_nkey.
    * define local data
      DATA:
       ld_nodetext    TYPE lvc_value,
       ls_outtab      TYPE ty_s_outtab.
      WRITE us_outtab-kunnr TO ld_nodetext+0  NO-ZERO.
      WRITE us_outtab-audat TO ld_nodetext+20 DD/MM/YYYY.
      CONDENSE ld_nodetext.
      " add node
      CALL METHOD go_alvtree->add_node
        EXPORTING
          i_relat_node_key = ud_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = ld_nodetext
          is_outtab_line   = us_outtab    " !!!
        IMPORTING
          e_new_node_key   = cd_node_key.
    ENDFORM.                    " add_complete_line
    *&      Form  register_events
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM register_events .
      DATA:
        lt_events TYPE cntl_simple_events,
        ls_event TYPE cntl_simple_event.
    * The following four tree events registers ALV Tree in the constructor
    * method itself.
    *    - cl_gui_column_tree=>eventid_expand_no_children
    * (needed to load data to frontend when a user expands a node)
    *    - cl_gui_column_tree=>eventid_header_context_men_req
    * (needed for header context menu)
    *    - cl_gui_column_tree=>eventid_header_click
    * (allows selection of columns (only when item selection activated))
    *   - cl_gui_column_tree=>eventid_item_keypress
    * (needed for F1-Help (only when item selection activated))
    * Nevertheless you have to provide their IDs again if you register
    * additional events with SET_REGISTERED_EVENTS (see below).
    * To do so, call first method  GET_REGISTERED_EVENTS (this way,
    * all already registered events remain registered, even your own):
      CALL METHOD go_alvtree->get_registered_events
        IMPORTING
          events = lt_events.
    * (If you do not these events will be deregistered!!!).
    * You do not have to register events of the toolbar again.
    * Register additional events for your own purposes:
    * §5. Register first context menu event on frontend (with postfix
    *     (_REQUEST). The second is registered automatically.
      ls_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
      APPEND ls_event TO lt_events.
    * register events on frontend
      CALL METHOD go_alvtree->set_registered_events
        EXPORTING
          events                    = lt_events
        EXCEPTIONS
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
      IF sy-subrc <> 0.
        MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
      ENDIF.
    * §6. Register both context menu events on backend (ABAP Objects
    *    event handling).
      SET HANDLER:
        lcl_eventhandler=>handle_node_ctxmenu_req  FOR go_alvtree,
        lcl_eventhandler=>handle_node_ctxmenu_sel  FOR go_alvtree.
    ENDFORM.                    " register_events
    Regards,
      Uwe

Maybe you are looking for

  • Ipod activation problems

    I reseted my ipod 5 and I need to sign in with my apple ID the problem is that when I go to the website and put it in its giving me one Apple ID but when I put it into my ipod it says that its incorrect so there is no way to access my ipod. What shou

  • Need help with Adobe Flash Player

    Youtube and several other websites can still identify that my flash player is up to date. Although, many websites including CNN, Aplia, and Southparkstudios do not recognize my flash player. I tried trouble shooting, reseting my axtiveX filter, updat

  • Trying to encode a large file small

    I am trying to send a film which is 150 meg. I used H.264. It looks great but way to big. I am not worried about the frame size. But I need to get the file down to about 10 meg. Because the video has alot of very quick stills timed to music, the resu

  • OBIEE integration with Hyperion MDM?

    Has anybody seen or worked on a project that integrated OBIEE with Hyperion MDM/DRM? I'm not familiar with MDM but it seems to me that MDM creates metadata that may overlap what OBIEE already has. Any information on this would be greatly helpful.

  • Settings allied data Copperjet 1616-2p and AEBS

    I am trying to install the Apple Airport Extreme BS in combination with an Allied data Copperjet 1616-2p modem/router. My internet connection should in optimal conditions be able to get to speeds of 2Mb/sec. In my settings, everything works, as long