Creating Context Menu in ALV tree defined inside DOCKING CONTAINER

Dear Experts.
Can you please tell me which EVENTS should i use in CLASS: CL_GUI_SIMPLE_TREE to get a Context menu after right click on any tree node in ALV Tree which has been defined inside a Docking Container.
Regards Arnab.

Hi,
Check Program SAPSIMPLE_TREE_CONTEXT_MEN_DEM and check event node_context_menu_request
Hope this helps you.
Thanks,
Prashanth
Edited by: Prashanth KR on Jun 2, 2009 7:50 AM

Similar Messages

  • How to create Context Menu for Full Screen ALV

    Dear Experts,
    Please tell me the procedure to create Context Menu for ALV Grid (full screen ALV using SLIS ).
    Regards
    Arnab

    Hi,
    Check the demo program BCALV_GRID_06

  • Creating Context menu on TREE control

    Hi,
    How to create Context menu on Tree (Nodes and Subnodes) in Web Dynpro for ABAP.
    Helpful answers will be rewarded.
    Regards,
    Jitesh.

    Hi
    You could go to the following link http://help.sap.com/saphelp_nw2004s/helpdata/en/21/ad884118aa1709e10000000a155106/frameset.htm .
    Also you could have a closer look at wdr_test_events example
    Thanks
    Anzy

  • Creating context menu on TREE

    Hi,
    How to create Context menu on Tree (Nodes and Subnodes) in Web Dynpro for ABAP.
    Helpful answers will be rewarded.
    Regards,
    Jitesh.

    hi jitesh,
    check out the sample tutorials in sap under the package : SWDP_DEMO_TUTORIALS
    thanks
    jaideep
    reward points if useful...

  • Define F-Code for ALV Button & context menu for ALV table

    Hi,
    I have some Buttons in ALV Toolbar like for example 'copy row'. Is it in browser environment possible to assign f-code to the button? Like by pushing e.g. F4 the method for 'copy row' action is fired?
    Or additionaly, is it possible to define a custom context menu in alv table?
    Thanks in advance,
    Tan

    Hi Tan,
    This Functionality is working on..Pelase check this...
    Re: How to improve Web accessibility with Function keys
    Re: Hot key(Ctrl+F1) for More field help not working
    Re: GUI Status?
    For help..
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/b951297a6d2d65e10000000a42189c/content.htm
    Cheers,
    Kris.
    Edited by: kissnas on Jun 21, 2011 11:46 AM

  • Creating Context Menu for JTree Node

    Hi to all,
    I need to create Context Menu, when i right click on any Tree Node.
    Context Menu should contain selected node information.
    if you click on one tree node named as "AAAA"
    Context Menu Format is as follows
    AAAA
    Create New
    Delete
    If any one knows, please help me

    Here is something for you to start
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=538065
    Denis Krukovsky
    http://dotuseful.sourceforge.net/

  • Modifying default context menu of  af:tree

    Hi all,
    this one is urgent..
    I am having a af:tree component on a jspx web page.
    I know that we can change the context menu (the box that pops out when right click happens on any of its node) by setting contextMenuId of the af:tree which points to a af:popup having af:menu. When we dont set contextMenuId; we get a default context menu displaying options to expand/collapse other nodes. When we set it to some af:popup component we get a different context menu.
    My requirment is that instead of getting a new context menu, i must be adding up my new options to the already existing default options in the context menu. So its a kind of extension of default context menu available.
    So can anybody help me.... i am a newbie so pls forgive me if i'm wrong somewhere..
    Thanks a lot..

    Hi Frank,
    thanks for the kind response..
    Yeah, i had tried that out too. But in this case the context menu that i'm defining doesn't seem to be picked up by af:tree since i'm only able to see the default context menu of the browser.
    This is strange since even the default context menu provided by af:tree doen't appear.
    Do we need to do something else also for that...
    By the way i assume that you were talking about contexMenu facet of af:tree only.
    I am inlinning the jspx code snippet for convinient.
    Can you please suggest something....
    <af:panelFormLayout customizationId="panelFormLayout1">
    <f:facet name="footer">
    <af:group>
    <af:commandButton text="commandButton 1"
    customizationId="commandButton1"/>
    <af:image source="http://www.google.com/intl/en_ALL/images/logo.gif"
    shortDesc="THE logo" customizationId="image1"/>
    <af:tree value="#{myBean.model}" var="model"
    rowSelection="single" initiallyExpanded="true"
    id="structureNavigatorTree" inlineStyle="padding:2px"
    contentDelivery="immediate"
    customizationId="amitKumarGupta">
    <f:facet name="nodeStamp">
    <af:panelGroupLayout>
    <af:outputText value="#{model.name}"/>
    </af:panelGroupLayout>
    </f:facet>
    <f:facet name="contextMenu">
    <af:popup id="yesItsgeneral">
    <af:menu id="fdssd" text="menu 1">
    <af:commandMenuItem id="micrsfdg" text="Expand All2"/>
    </af:menu>
    </af:popup>
    </f:facet>
    </af:tree>
    </af:group>
    </f:facet>
    </af:panelFormLayout>
    </cust:panelCustomizable>
    <f:facet name="editor">
    <pe:pageEditorPanel/>
    </f:facet>
    </pe:pageCustomizable>
    </af:form>
    </af:document>
    Hi,
    turns out the solution is easy. Just use the context
    menu facet, similar to below
    <f:facet name="contextMenu">
    <af:popup>
    <af:menu text="menu 1">
    <af:commandMenuItem text="Expand
    All2"/>
    </af:menu>
    /af:popup>
    </f:facet>
    custom menu to the existing set of menus
    Frank

  • How to create a context menu in ALV table cell editor(Webdynpro abap )

    Hello Experts,
    I am having a problem in creating a context menu in a table cell editor in the ALV table output.I have assigned a 'lta' as the cell editor.But befor assigning the lta as cell editor I have assigned the menu to the lta.But when the view is rendered I can see the lta with the actioned assigned to it.But I cannot see the context menu.
    The code snippet below:
      "Create menu for each coloumn
      create OBJECT lo_menu_actions type CL_SALV_WD_VE_MENU EXPORTING
          id = 'MITM_ACTIONS'.
      lo_menu_actions->set_visible( value = abap_true ). 
      lo_menu_actions->set_visible_fieldname( value = 'ACTIONS' ).
      "ADd menu items
      CREATE OBJECT lo_menu_item_create type CL_SALV_WD_VE_MENU
      exporting
        id = 'MITM_CREATE_EXPRESSION'.
      lo_menu_item_create->set_visible( value = abap_true ).
      lo_menu_item_create->set_visible_fieldname( value = 'Create' ).
      "Add item 1
      lo_menu_actions->ADD_ITEM( VALUE = lo_menu_item_create ). 
      "  Set the cell editor for each column cell(link to an action)
      LOOP AT lt_node_dec_tab_cols INTO ls_node_dec_tab_cols .
        lv_column_name = ls_node_dec_tab_cols-object_name.
        lr_column = lr_column_settings->get_column( lv_column_name ).
       "Create 'lta' Ui item
        CREATE OBJECT lo_lta TYPE cl_salv_wd_uie_link_to_action.
        lo_lta->set_menu( value = lo_menu_actions ).
        lo_lta->set_text_fieldname( lv_column_name ).
        lr_column->set_cell_editor( lo_lta ).
        IF ls_node_dec_tab_cols-is_result EQ abap_true.
          lr_column->set_cell_design( value =
                      cl_wd_table_column=>e_cell_design-key_medium ).
        ENDIF.
      ENDLOOP.

    Hi Prakash,
    I have not come across this requirement till now to have context menu in a cell editor of alv.
    Unfortunately  the implementation of method SET_MENU of alv ui elements ( ex: cl_salv_wd_uie_text_view ) is not updating alv configurable table, instead it just stores in a global attribute as string. Hence has no effect on context menu.
    If your user is very particular about this requirement of having context menu in cell editor, you can go for a normal table. Because, normal table's cell editor has the property to set the menuID as we do it for other ui elements.
    Regards,
    Rama

  • Context menu of adf tree not working properly in firefox

    hi all,
    I am creating a context menu using the context facet in <adf:tree>. Everything is working fine in both chrome and ie but the issue is with firefox.It's opening up the browser window and rarely showing up the context menu
    Any help would be appreciated.
    Here is the code
    <af:tree value="#{bindings.FormSectionsView1.treeModel}" var="node"
    selectionListener="#{bindings.FormSectionsView1.treeModel.makeCurrent}"
    rowSelection="single" id="t1">
    <f:facet name="nodeStamp">
    <af:outputText value="#{node}" id="ot1"/>
    </f:facet>
    <f:facet name="contextMenu">
    <af:popup childCreation="deferred" autoCancel="disabled" id="p1">
    <af:menu text="menu 1" id="m2">
    <af:commandMenuItem text="commandMenuItem 1" id="cmi1"/>
    <af:commandMenuItem text="commandMenuItem 2" id="cmi2"/>
    </af:menu>
    </af:popup>
    </f:facet>
    </af:tree>
    Thanks,
    Raj

    Raj,
    Welcome to OTN. Always mention your JDev version (read through this announcement : https://forums.oracle.com/forums/ann.jspa?annID=56 )
    Try running the tree demo in your browser and see if it works fine (Right click on any node to bring up the context menu).
    http://jdevadf.oracle.com/adf-richclient-demo/faces/components/tree.jspx
    -Arun

  • How To Create Context Menu In Module Pool

    Moderator message: do not offer points
    hello guru's
    Please help me regarding creation of context menu in MODULE POOL Programming.
    pleaase send me link or procedure to create it.
    <<text removed>>
    waiting for reply
    Edited by: Matt on Feb 20, 2009 3:13 PM

    Do a search first:
    [link1|context menus;
    [link2|http://help.sap.com/saphelp_nw04/helpdata/en/e2/5d3bb2e06411d295a900a0c94260a5/frameset.htm]
    etc. etc.

  • Dynamically create context menu

    I'm trying to create a context menu based on a certain af:commandImageLink.
    I have an af:popup with an af:menu in my page. I bound the af:menu to my bean so I can change the content. I didn't put any children in the menu to start because I want to add the children based on the image that's click.
    I added an af:showPopupBehavior to show my popup on click. The idea was that I wanted to use the actionListener of the af:commandImageLink to dynamically create the menu that I need. But it seems that the actionListener fires after the showPopupBehavior most times. On the first click, it looks like the actionListener fires first then the showPopupBehavior. After that, it seems the actionListener always fires after.
    So it looks like this is not really supposed to work.
    Does anyone have any suggestions on how this should be made to work?

    Thanks a lot Timo,
    This does allow me to control when the popup shows up.
    I modified the code you gave slightly to include code to align the popup:
        public static void showPopup(String popupId, String alignId) {
            FacesContext context = FacesContext.getCurrentInstance();
            StringBuilder script = new StringBuilder();
            script.append("var popup = AdfPage.PAGE.findComponent('").append(popupId).append("'); ").append("if (!popup.isPopupVisible()) { ")
                .append("var hints = {}; ").append("hints[AdfRichPopup.HINT_ALIGN_ID] = '").append(alignId).append("'; ")
                .append("hints[AdfRichPopup.HINT_ALIGN] = AdfRichPopup.ALIGN_AFTER_END; ").append("popup.show(hints);}");
            ExtendedRenderKitService erks = Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);
            erks.addScript(context, script.toString());
        }I still have some problems though. I need to give some more context on this.
    So I have an af:iterator that shows a list of images. I'm trying to popup a context menu when they click the image. The menu needs to be aligned relative to the image that was clicked.
    However, when I tried to get the ID from the ActionEvent, I get the design time ID which should not be the same as the run time ID because the iterator would have created multiple instances of the image, each with a unique ID. I'm assuming that's why the alignment is not working.
    Am I missing something here?
    Also, I seem to be having problems with modifying the menu. Here's my bean code:
        private RichMenu baseMenu;
        public void imageActionListener(ActionEvent actionEvent) {
            Object o = actionEvent.getComponent();
            RichCommandImageLink image = (RichCommandImageLink)o;
            DCIteratorBinding iteLoc = ADFUtils.findIterator("OpItemLocationsVO2Iterator");
            for(Row row : iteLoc.getAllRowsInRange()) {
                OpItemLocationsVORowImpl r = (OpItemLocationsVORowImpl)row;
                RichCommandMenuItem a = new RichCommandMenuItem();
                Number n = r.getItelocId().getSequenceNumber();
                a.setId("i" + r.getItelocId().getSequenceNumber().toString());
                a.setText(r.getItelocId().getSequenceNumber().toString());
                baseMenu.getChildren().add(a);
            AdfFacesContext.getCurrentInstance().addPartialTarget(baseMenu);
            showPopup("vmenu", image.getId());
        }So in my popup, I added a menu and I bound that menu to this bean. The idea was that whenever an image was clicked, I would remove all the children from the menu, then add the new ones. There would be a master-detail relationship between the image's iterator and the menu that's supposed to show up.
    The other problems that I'm getting with this is that the menu is not changing when I click on a different image. When I debug, I'll see the correct values being added, but nothing changes on the screen. It's always showing the first popup that was ever created. Also, I don't know how to remove the previous children. There doesn't seem to be an API to remove the children.
    Thoughts?

  • Creating Input Field inside Docking Container bar

    Hello.
    Does anyone know how I can put an input field inside a docking container object ? Just like it appears in SE80.
    I have created a docking container bar, and in one of those bars i want to put a text field.
    Anyone please ?
    Thank you
    EDIT----
    I found how to do this with cl_gui_container_bar_2 and with dynamic documents.
    Edited by: Ricardo Monteiro on Aug 25, 2010 1:30 PM

    Hi,
    Check Program SAPSIMPLE_TREE_CONTEXT_MEN_DEM and check event node_context_menu_request
    Hope this helps you.
    Thanks,
    Prashanth
    Edited by: Prashanth KR on Jun 2, 2009 7:50 AM

  • Place a Tabstrips Inside Docking Container

    All,
    I have a docking container like the following
    i need to place a tabstrip in the bottom container. I have the following code
    if gc_docking_t is initial.
        create object gc_docking_t
           exporting
             repid     = sy-repid
             dynnr     = '0300'
             extension = 75
             style     = style
             side      = cl_gui_docking_container=>dock_at_top
             metric    = cl_gui_docking_container=>metric_pixel.
      endif.
      if gc_docking_l is initial.
        create object gc_docking_l
          exporting repid = sy-repid
          dynnr = '0300'
          extension = 9999
          side = cl_gui_docking_container=>dock_at_bottom.
      endif.
    I have created a screen 310 with tabstrips inside, how can i call this screen inside this docking container
    Any Info ?

    Hi,
    SCN -Wiki->My Home->Code Gallery->Community Code Gallery->TabStrip in ALV(OOPS)
    Please refer http://wiki.sdn.sap.com/wiki/display/Snippets/TabStripinALV(OOPS)

  • Abnormality while creating Context Menu

    Hi All,
              When i was working with context menus it is found that the context menus having label like "Copy" "Delete" are not been created..
    Any Idea..
      Thanks And Regards
       Abdul Jaleel C

    If found out that some labels are simply not displayed. If you create a custom menu item with a label like "Adobe" for example, it won't appear.
    I also created this method to ease the addition of menu items:
                 private function createMenuItem(
                     menu:ContextMenu,
                     handler:Function,
                     caption:String,
                     separator:Boolean,
                     enabled:Boolean = true,
                     visible:Boolean = true):void
                     var menuItem:ContextMenuItem = new ContextMenuItem(caption, separator, enabled, visible);
                     menuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, handler);
                     menu.customItems.push(menuItem);                

  • 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