If you look at Object Navigator (T-code SE80), you can see that the right screen continues to change while the left screen remains the same according to the information selected in the tree on the left. As such, a docking container that operates regardless of screen changes can be implemented as a simple option.

Let’s implement a tree that has a menu that simply moves between screens, and implements a screen that changes depending on the selection.

First, if we implement it as a general docking container we know without changing any options, it becomes as follows.

In this program, if screen number 200 is selected, the left tree disappears and only screen 200 appears as shown below.

[Case of General]

However, by changing only one option, it can be implemented as follows.

[Case of Option Specified]

 

1. Create docking container and menus

CLASS lcl_docker DEFINITION
  INHERITING FROM cl_gui_docking_container.

  PUBLIC SECTION.
    METHODS constructor IMPORTING iv_no_autodef TYPE abap_bool.

  PRIVATE SECTION.
    DATA mo_tree TYPE REF TO cl_gui_alv_tree.
    DATA mt_menu TYPE TABLE OF scmgreadmenuitem.
    DATA ms_current_menu LIKE LINE OF mt_menu.

    METHODS handle_node_double_click FOR EVENT node_double_click OF cl_gui_alv_tree
      IMPORTING node_key.
ENDCLASS.

CLASS lcl_docker IMPLEMENTATION.
  METHOD constructor.
    super->constructor( side                    = dock_at_left
                        ratio                   = 30 ).

    mo_tree = NEW #( parent         = me
                     no_html_header = abap_true
                     no_toolbar     = abap_true
                     item_selection = abap_false ).
    mo_tree->set_table_for_first_display( EXPORTING i_structure_name    = 'SCMGREADMENUITEM'
                                                    is_hierarchy_header = VALUE #( heading = 'Menu' width = 50 )
                                          CHANGING  it_outtab           = mt_menu ).

    mo_tree->add_node( EXPORTING i_relat_node_key = space
                                 i_relationship   = cl_gui_column_tree=>relat_last_child
                                 is_node_layout   = VALUE #( isfolder = abap_true )
                                 i_node_text      = 'Root'
                       IMPORTING e_new_node_key   = DATA(root_node) ).

    mo_tree->add_node( EXPORTING i_relat_node_key = root_node
                                 i_relationship   = cl_gui_column_tree=>relat_last_child
                                 is_outtab_line   = VALUE scmgreadmenuitem( event_name = 'Screen 100' menu_item = '0100' )
                                 is_node_layout   = VALUE #( isfolder = abap_false )
                                 i_node_text      = 'Go to 100' ).
    mo_tree->add_node( EXPORTING i_relat_node_key = root_node
                                 i_relationship   = cl_gui_column_tree=>relat_last_child
                                 is_outtab_line   = VALUE scmgreadmenuitem( event_name = 'Screen 200' menu_item = '0200' )
                                 is_node_layout   = VALUE #( isfolder = abap_false )
                                 i_node_text      = 'Go to 200' ).
    mo_tree->frontend_update( ).
    mo_tree->expand_node( i_node_key       = root_node
                          i_expand_subtree = abap_true ).

    ms_current_menu-menu_item = '0100'.

    mo_tree->set_registered_events( VALUE #( ( eventid = cl_gui_column_tree=>eventid_node_double_click ) ) ).

    SET HANDLER handle_node_double_click FOR mo_tree.
  ENDMETHOD.

2. Event Handler

  METHOD handle_node_double_click.
    DATA ls_outtab TYPE scmgreadmenuitem.

    mo_tree->get_outtab_line( EXPORTING i_node_key    = node_key
                              IMPORTING e_outtab_line = ls_outtab ).

    CHECK ms_current_menu-menu_item <> ls_outtab-menu_item.

    ms_current_menu = ls_outtab.

    cl_gui_cfw=>set_new_ok_code( CONV #( ls_outtab-menu_item ) ).

  ENDMETHOD.

 

3. User Command

MODULE pai INPUT.
  CASE sy-ucomm.
    WHEN '0100'. LEAVE TO SCREEN 100.
    WHEN '0200'. LEAVE TO SCREEN 200.
    WHEN OTHERS. LEAVE TO SCREEN 0.
  ENDCASE.
ENDMODULE.

 

When the program is configured like this, the same result as [Case of General] is obtained. However, you can get what you want with the following modifications:

    super->constructor( side                    = dock_at_left
                        ratio                   = 30
                        no_autodef_progid_dynnr = abap_true ).

It’s a very simple way, but the results are powerful. However, since it has nothing to do with screen movement, event handling and program flow require a lot of thought.

For reference, there are three more containers that have this option:

CL_GUI_DIALOGBOX_CONTAINER

CL_GUI_CUSTOM_CONTAINER

CL_GUI_SPLITTER_CONTAINER

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x