<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: user command in trees in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310307#M161543</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hii&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Insert the following code into the PBO of the screen after the ALVtree has been created.&lt;/P&gt;&lt;P&gt;	i.e after 'CALL METHOD gd_tree&amp;gt;set_table_for_first_display' has been executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      REGISTER_EVENTS
*&amp;amp;---------------------------------------------------------------------*

* 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=&amp;gt;eventid_expand_no_children.
  append l_event to lt_events.
  l_event-eventid = cl_gui_column_tree=&amp;gt;eventid_checkbox_change.
  append l_event to lt_events.
  l_event-eventid = cl_gui_column_tree=&amp;gt;eventid_header_context_men_req.
  append l_event to lt_events.
  l_event-eventid = cl_gui_column_tree=&amp;gt;eventid_node_context_menu_req.
  append l_event to lt_events.
  l_event-eventid = cl_gui_column_tree=&amp;gt;eventid_item_context_menu_req.
  append l_event to lt_events.
  l_event-eventid = &amp;lt;b&amp;gt;cl_gui_column_tree=&amp;gt;eventid_item_double_click.
  append l_event to lt_events.&amp;lt;/b&amp;gt;
  l_event-eventid = cl_gui_column_tree=&amp;gt;eventid_header_click.
  append l_event to lt_events.
  l_event-eventid = cl_gui_column_tree=&amp;gt;eventid_item_keypress.
  append l_event to lt_events.

  call method gd_tree-&amp;gt;set_registered_events
    exporting
      events = lt_events
    exceptions
      cntl_error                = 1
      cntl_system_error         = 2
      illegal_event_combination = 3.
  if sy-subrc &amp;lt;&amp;gt; 0.
    message x208(00) with 'ERROR'.                       "#EC NOTEXT
  endif.



* set Handler
  data: l_event_receiver type ref to lcl_tree_event_receiver.
  create object l_event_receiver.
  set handler l_event_receiver&amp;gt;handle_node_ctmenu_request
                                                      for gd_tree.
  set handler l_event_receiver-&amp;gt;handle_node_ctmenu_selected
                                                        for gd_tree.
  set handler l_event_receiver-&amp;gt;handle_item_ctmenu_request
                                                        for gd_tree.
  set handler l_event_receiver-&amp;gt;handle_item_ctmenu_selected
                                                        for gd_tree.
  &amp;lt;b&amp;gt;set handler l_event_receiver-&amp;gt;handle_item_double_click
                                                        for gd_tree.&amp;lt;/b&amp;gt;
  set handler l_event_receiver-&amp;gt;handle_header_click
                                                        for gd_tree.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Define class to handle user interaction other than via toolbar buttons. Insert at end of DATA declaration &lt;/P&gt;&lt;P&gt;section but before any ABAP processing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*----------------------------------------------------------------------*
*   INCLUDE BCALV_TREE_EVENT_RECEIVER                                  *
*----------------------------------------------------------------------*
CLASS lcl_tree_event_receiver DEFINITION.

  PUBLIC SECTION.

    METHODS handle_node_ctmenu_request
      FOR EVENT node_context_menu_request OF cl_gui_alv_tree
        IMPORTING node_key
                  menu.
    METHODS handle_node_ctmenu_selected
      FOR EVENT node_context_menu_selected OF cl_gui_alv_tree
        IMPORTING node_key
                  fcode.
    METHODS handle_item_ctmenu_request
      FOR EVENT item_context_menu_request OF cl_gui_alv_tree
        IMPORTING node_key
                  fieldname
                  menu.
    METHODS handle_item_ctmenu_selected
      FOR EVENT item_context_menu_selected OF cl_gui_alv_tree
        IMPORTING node_key
                  fieldname
                  fcode.

    &amp;lt;b&amp;gt;METHODS handle_item_double_click
      FOR EVENT item_double_click OF cl_gui_alv_tree
      IMPORTING node_key
                fieldname.&amp;lt;/b&amp;gt;

    METHODS handle_button_click
      FOR EVENT button_click OF cl_gui_alv_tree
      IMPORTING node_key
                fieldname.

    METHODS handle_link_click
      FOR EVENT link_click OF cl_gui_alv_tree
      IMPORTING node_key
                fieldname.

    METHODS handle_header_click
      FOR EVENT header_click OF cl_gui_alv_tree
      IMPORTING fieldname.

ENDCLASS.

*---------------------------------------------------------------------*
*       CLASS lcl_tree_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
CLASS lcl_tree_event_receiver IMPLEMENTATION.

  METHOD handle_node_ctmenu_request.
*   append own functions
    CALL METHOD menu-&amp;gt;add_function
                EXPORTING fcode   = 'USER1'
                          text    = 'Usercmd 1'.            "#EC NOTEXT
    CALL METHOD menu-&amp;gt;add_function
                EXPORTING fcode   = 'USER2'
                          text    = 'Usercmd 2'.            "#EC NOTEXT
    CALL METHOD menu-&amp;gt;add_function
                EXPORTING fcode   = 'USER3'
                          text    = 'Usercmd 3'.            "#EC NOTEXT
  ENDMETHOD.

  METHOD handle_node_ctmenu_selected.
    CASE fcode.
      WHEN 'USER1' OR 'USER2' OR 'USER3'.
        MESSAGE i000(0h) WITH 'Node-Context-Menu on Node ' node_key
                              'fcode : ' fcode.             "#EC NOTEXT
    ENDCASE.
  ENDMETHOD.

  METHOD handle_item_ctmenu_request .
*   append own functions
    CALL METHOD menu-&amp;gt;add_function
                EXPORTING fcode   = 'USER1'
                          text    = 'Usercmd 1'.
    CALL METHOD menu-&amp;gt;add_function
                EXPORTING fcode   = 'USER2'
                          text    = 'Usercmd 2'.
    CALL METHOD menu-&amp;gt;add_function
                EXPORTING fcode   = 'USER3'
                          text    = 'Usercmd 3'.
  ENDMETHOD.

  METHOD handle_item_ctmenu_selected.
    CASE fcode.
      WHEN 'USER1' OR 'USER2' OR 'USER3'.
        MESSAGE i000(0h) WITH 'Item-Context-Menu on Node ' node_key
                              'Fieldname : ' fieldname.     "#EC NOTEXT
    ENDCASE.
  ENDMETHOD.

  METHOD handle_item_double_click.
* Processing for when user double clicks on ALVtree
  ENDMETHOD.

  METHOD handle_button_click.
* Processing when user clicks button   
  ENDMETHOD.

  METHOD handle_link_click.
* ??  
  ENDMETHOD.

  METHOD handle_header_click.
* Processing for when user clicks on ALVtree column headers 
  ENDMETHOD.

ENDCLASS.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Naresh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 08 Jun 2006 13:20:56 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-06-08T13:20:56Z</dc:date>
    <item>
      <title>user command in trees</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310306#M161542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I created trees which displays kunnr value of kna1 table.My requirement is whenever i double click on that  kunnr it must display the sales document number from the vbak table for that corresponding kunnr value..&lt;/P&gt;&lt;P&gt;how to use user command in trees.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Deepa&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2006 13:14:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310306#M161542</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-08T13:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: user command in trees</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310307#M161543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hii&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Insert the following code into the PBO of the screen after the ALVtree has been created.&lt;/P&gt;&lt;P&gt;	i.e after 'CALL METHOD gd_tree&amp;gt;set_table_for_first_display' has been executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      REGISTER_EVENTS
*&amp;amp;---------------------------------------------------------------------*

* 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=&amp;gt;eventid_expand_no_children.
  append l_event to lt_events.
  l_event-eventid = cl_gui_column_tree=&amp;gt;eventid_checkbox_change.
  append l_event to lt_events.
  l_event-eventid = cl_gui_column_tree=&amp;gt;eventid_header_context_men_req.
  append l_event to lt_events.
  l_event-eventid = cl_gui_column_tree=&amp;gt;eventid_node_context_menu_req.
  append l_event to lt_events.
  l_event-eventid = cl_gui_column_tree=&amp;gt;eventid_item_context_menu_req.
  append l_event to lt_events.
  l_event-eventid = &amp;lt;b&amp;gt;cl_gui_column_tree=&amp;gt;eventid_item_double_click.
  append l_event to lt_events.&amp;lt;/b&amp;gt;
  l_event-eventid = cl_gui_column_tree=&amp;gt;eventid_header_click.
  append l_event to lt_events.
  l_event-eventid = cl_gui_column_tree=&amp;gt;eventid_item_keypress.
  append l_event to lt_events.

  call method gd_tree-&amp;gt;set_registered_events
    exporting
      events = lt_events
    exceptions
      cntl_error                = 1
      cntl_system_error         = 2
      illegal_event_combination = 3.
  if sy-subrc &amp;lt;&amp;gt; 0.
    message x208(00) with 'ERROR'.                       "#EC NOTEXT
  endif.



* set Handler
  data: l_event_receiver type ref to lcl_tree_event_receiver.
  create object l_event_receiver.
  set handler l_event_receiver&amp;gt;handle_node_ctmenu_request
                                                      for gd_tree.
  set handler l_event_receiver-&amp;gt;handle_node_ctmenu_selected
                                                        for gd_tree.
  set handler l_event_receiver-&amp;gt;handle_item_ctmenu_request
                                                        for gd_tree.
  set handler l_event_receiver-&amp;gt;handle_item_ctmenu_selected
                                                        for gd_tree.
  &amp;lt;b&amp;gt;set handler l_event_receiver-&amp;gt;handle_item_double_click
                                                        for gd_tree.&amp;lt;/b&amp;gt;
  set handler l_event_receiver-&amp;gt;handle_header_click
                                                        for gd_tree.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Define class to handle user interaction other than via toolbar buttons. Insert at end of DATA declaration &lt;/P&gt;&lt;P&gt;section but before any ABAP processing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*----------------------------------------------------------------------*
*   INCLUDE BCALV_TREE_EVENT_RECEIVER                                  *
*----------------------------------------------------------------------*
CLASS lcl_tree_event_receiver DEFINITION.

  PUBLIC SECTION.

    METHODS handle_node_ctmenu_request
      FOR EVENT node_context_menu_request OF cl_gui_alv_tree
        IMPORTING node_key
                  menu.
    METHODS handle_node_ctmenu_selected
      FOR EVENT node_context_menu_selected OF cl_gui_alv_tree
        IMPORTING node_key
                  fcode.
    METHODS handle_item_ctmenu_request
      FOR EVENT item_context_menu_request OF cl_gui_alv_tree
        IMPORTING node_key
                  fieldname
                  menu.
    METHODS handle_item_ctmenu_selected
      FOR EVENT item_context_menu_selected OF cl_gui_alv_tree
        IMPORTING node_key
                  fieldname
                  fcode.

    &amp;lt;b&amp;gt;METHODS handle_item_double_click
      FOR EVENT item_double_click OF cl_gui_alv_tree
      IMPORTING node_key
                fieldname.&amp;lt;/b&amp;gt;

    METHODS handle_button_click
      FOR EVENT button_click OF cl_gui_alv_tree
      IMPORTING node_key
                fieldname.

    METHODS handle_link_click
      FOR EVENT link_click OF cl_gui_alv_tree
      IMPORTING node_key
                fieldname.

    METHODS handle_header_click
      FOR EVENT header_click OF cl_gui_alv_tree
      IMPORTING fieldname.

ENDCLASS.

*---------------------------------------------------------------------*
*       CLASS lcl_tree_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
CLASS lcl_tree_event_receiver IMPLEMENTATION.

  METHOD handle_node_ctmenu_request.
*   append own functions
    CALL METHOD menu-&amp;gt;add_function
                EXPORTING fcode   = 'USER1'
                          text    = 'Usercmd 1'.            "#EC NOTEXT
    CALL METHOD menu-&amp;gt;add_function
                EXPORTING fcode   = 'USER2'
                          text    = 'Usercmd 2'.            "#EC NOTEXT
    CALL METHOD menu-&amp;gt;add_function
                EXPORTING fcode   = 'USER3'
                          text    = 'Usercmd 3'.            "#EC NOTEXT
  ENDMETHOD.

  METHOD handle_node_ctmenu_selected.
    CASE fcode.
      WHEN 'USER1' OR 'USER2' OR 'USER3'.
        MESSAGE i000(0h) WITH 'Node-Context-Menu on Node ' node_key
                              'fcode : ' fcode.             "#EC NOTEXT
    ENDCASE.
  ENDMETHOD.

  METHOD handle_item_ctmenu_request .
*   append own functions
    CALL METHOD menu-&amp;gt;add_function
                EXPORTING fcode   = 'USER1'
                          text    = 'Usercmd 1'.
    CALL METHOD menu-&amp;gt;add_function
                EXPORTING fcode   = 'USER2'
                          text    = 'Usercmd 2'.
    CALL METHOD menu-&amp;gt;add_function
                EXPORTING fcode   = 'USER3'
                          text    = 'Usercmd 3'.
  ENDMETHOD.

  METHOD handle_item_ctmenu_selected.
    CASE fcode.
      WHEN 'USER1' OR 'USER2' OR 'USER3'.
        MESSAGE i000(0h) WITH 'Item-Context-Menu on Node ' node_key
                              'Fieldname : ' fieldname.     "#EC NOTEXT
    ENDCASE.
  ENDMETHOD.

  METHOD handle_item_double_click.
* Processing for when user double clicks on ALVtree
  ENDMETHOD.

  METHOD handle_button_click.
* Processing when user clicks button   
  ENDMETHOD.

  METHOD handle_link_click.
* ??  
  ENDMETHOD.

  METHOD handle_header_click.
* Processing for when user clicks on ALVtree column headers 
  ENDMETHOD.

ENDCLASS.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Naresh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2006 13:20:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310307#M161543</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-08T13:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: user command in trees</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310308#M161544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refer to &amp;lt;b&amp;gt;BCALV_TREE_02&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;for event handling in trees&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u can also search &amp;lt;b&amp;gt;bcalv*&amp;lt;/b&amp;gt; in se38 &amp;amp; can alist of alv tree programs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;plz reward if useful&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2006 13:28:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310308#M161544</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-08T13:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: user command in trees</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310309#M161545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you should have local event handler method to respond the double click on item.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHODS handle_item_double_click
      FOR EVENT item_double_click OF cl_gui_alv_tree
      IMPORTING node_key
                fieldname.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the above one should be implemented and then need to set the handler.&lt;/P&gt;&lt;P&gt;in the implementation get the order number and set the parameter id, and then call transaction TCODE skip initial screen ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2006 13:29:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310309#M161545</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-08T13:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: user command in trees</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310310#M161546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer the demo program :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAPSIMPLE_TREE_CONTROL_DEMO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Reward points if it helps.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2006 13:40:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310310#M161546</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-08T13:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: user command in trees</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310311#M161547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi contact,&lt;/P&gt;&lt;P&gt;check this link:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sapdevelopment.co.uk/reporting/alv/alvtree%5Calvtree_basic.htm" target="test_blank"&gt;http://www.sapdevelopment.co.uk/reporting/alv/alvtree%5Calvtree_basic.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if helpful.&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;keerthi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Jun 2006 16:37:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/user-command-in-trees/m-p/1310311#M161547</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-08T16:37:02Z</dc:date>
    </item>
  </channel>
</rss>

