ALVtree user interaction processing

Define class to handle user interaction other than via toolbar buttons. Insert at end of DATA declaration section but before any ABAP processing.


*--------------------------------------------------------------*
*   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.
    METHODS handle_item_double_click
      FOR EVENT item_double_click OF cl_gui_alv_tree
      IMPORTING node_key
                fieldname.
    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->add_function
                EXPORTING fcode   = 'USER1'
                          text    = 'Usercmd 1'.            "#EC NOTEXT
    CALL METHOD menu->add_function
                EXPORTING fcode   = 'USER2'
                          text    = 'Usercmd 2'.            "#EC NOTEXT
    CALL METHOD menu->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->add_function
                EXPORTING fcode   = 'USER1'
                          text    = 'Usercmd 1'.
    CALL METHOD menu->add_function
                EXPORTING fcode   = 'USER2'
                          text    = 'Usercmd 2'.
    CALL METHOD menu->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.

Related Articles

Activate user interaction within SAP ALV tree
Add button to SAP ALV tree toolbar using ABAP code
ABAP ALV Tree tutorial to create a fully working ALVTree Control SAP dynpro program
Create ALV Tree Custom control and add to sap dynpro screen
Final ABAP code for the ALV Tree PBO(..O01) and FORM(..F01) includes
Create SAP ALV Tree Container in ABAP dynpro screen container
Create Container and Object
Create ALV tree main program including Data & Event declaration
SAP ALV Tree fieldcatalog creation
Set SAP ALV tree table for first display and user interaction
Build SAP ALV tree Hierarchy
Build SAP ALV tree Hierarchy Header
Add alv tree already exists check to pbo module
Create all includes required for the ALV tree report
Full ABAP code listing of main ALV tree program
Module creation screen
Create SAP ALV Tree object within ABAP dynpro screen container/H1>
Create ok code to store ALV tree user interaction
Example Output from ALV tree display
Create screen control
Create Screen along with PBO and PAI modules
Create Pf-status(screen menu functionality)
Refresh ALVtree
Build Report Header(Title)
ALVtree toolbar processing
Implement user defined buttons to ALVtree toolbar
Implement ALVtree user interaction processing
Setup ALVtree variant
Main Steps to create ALV simple Tree(Using Objects)
Create Add Custom control to screen
Final code for the PBO(..O01) and FORM(..F01) includes
Create Container and Object
Create and register events for user interaction
Create ALVtree Hierarchy
Add already exists check!
Create Includes for ALVtree report
Full ABAP code listing of main program
Create Container and Object
Create screen control
Example Output from ALV simple tree display
Create screen control
Create Screen along with PBO and PAI modules
Create Pf-status(screen menu functionality)