Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
naresh_bammidi
Contributor

Expected Output

  Create a  Webdynpro component

   Insert UI Element MenuBar

  Right Click on Men Bar->Insert Menu

  Create one more menu(Submenu) under UI element MENU

  Give title to the sub menu

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

  Now Bind the attribute to Menu title

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

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.

4 Comments
Labels in this area