Skip to Content

Expected Output

Expected_op.png

  Create a  Webdynpro component

/wp-content/uploads/2013/03/1_194256.png

   Insert UI Element MenuBar

/wp-content/uploads/2013/03/2_194257.png

  Right Click on Men Bar->Insert Menu

/wp-content/uploads/2013/03/3_194272.png

  Create one more menu(Submenu) under UI element MENU

/wp-content/uploads/2013/03/4_194276.png

/wp-content/uploads/2013/03/5_194260.png

  Give title to the sub menu

/wp-content/uploads/2013/03/6_194261.png

     Create an attribute in View context and Give default value as <Select>(To display default text).

/wp-content/uploads/2013/03/7_194262.png

  Now Bind the attribute to Menu title

/wp-content/uploads/2013/03/8_194263.png

Usually WDDOMODIFYVIEW Method will be executed before displaying the screen. So write the below code
to fill the values into menu.

For the reference Below is the Hook methods order of execution

Doinit                       – Component Controller
Doinit                       – Window Controller
Doinit                       – View
Handle default         – Window Controller
Before navigation    – Component Controller
Modify View            – View
Post processing      – Component Controller

——— After user interaction(Clicking on Button)———

Before action                    – view
On action Event handler   – view
after action                        – view
Before navigation              – Component Controller
Modify view                       – View
Post processing                – Component Controller

/wp-content/uploads/2013/03/9_194264.png

METHOD wddomodifyview .

  IF first_time = abap_true.

* Data Decleration.

    TYPES:BEGIN OF ty_menu,
          m_item(100)
TYPE c,
         
END OF ty_menu.

    DATA lt_menu TYPE TABLE OF ty_menu.
   
DATA ls_menu TYPE ty_menu.


* Sample menu items

    ls_menu-m_item = ‘Display Object List’.
   
APPEND ls_menu TO lt_menu.
   
CLEAR  ls_menu.

    ls_menu-m_item = ‘Display Navigation Window’.
   
APPEND ls_menu TO lt_menu.
   
CLEAR  ls_menu.

    ls_menu-m_item = ‘Update Navigation Index’.
   
APPEND ls_menu TO lt_menu.
   
CLEAR  ls_menu.

    ls_menu-m_item = ‘Where Used list’.
   
APPEND ls_menu TO lt_menu.
   
CLEAR  ls_menu.

    ls_menu-m_item = ‘Versions’.
   
APPEND ls_menu TO lt_menu.
   
CLEAR  ls_menu.

    ls_menu-m_item = ‘Work List’.
   
APPEND ls_menu TO lt_menu.
   
CLEAR  ls_menu.

    ls_menu-m_item = ‘Inactive Objects’.
   
APPEND ls_menu TO lt_menu.
   
CLEAR  ls_menu.

    ls_menu-m_item = ‘Modification Browser’.
   
APPEND ls_menu TO lt_menu.
   
CLEAR  ls_menu.

* Filling out Menu items

    DATA lv_key                              TYPE string.
   
DATA menu_radio_button_item TYPE REF TO cl_wd_menu_radiobutton.
   
DATA lv_index                            TYPE sy-tabix.
   
DATA menu                                TYPE REF TO cl_wd_menu.

    LOOP AT lt_menu INTO ls_menu.

      lv_index = sy-tabix.

* Here am filling first 5 records from the internal table in MAIN menu and remaining values in submenu

      IF lv_index <= 5.
        menu ?= view->get_element(
‘MENU’ ).” Menu which we created in view
      ELSE.
        menu ?= view->get_element(
‘SM_OTHER’ ). ” Sub menu which we created in view
      ENDIF.

      lv_key = LS_MENU-M_ITEM.


* Method to fill menu items with radio buttons

      CALL METHOD cl_wd_menu_radiobutton=>new_menu_radiobutton

        EXPORTING
          bind_selected_key =
‘MENU’ ” Selected value will be binded to the attribute ‘MENU’
          key_to_select     = lv_key
         
text              = lv_key
        RECEIVING
         
control           = menu_radio_button_item.

* Add the menu items to the respective Menu

      menu->add_item( EXPORTING index = lv_index
                               the_item = menu_radio_button_item ).

    ENDLOOP.

  ENDIF.

ENDMETHOD.

Now Create Webdynpro application and Execute it.

/wp-content/uploads/2013/03/10_194270.png

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply