context menus webdynpro

7
Context Menus in Webdynpro ABAP -> Create a Webdynpro Component via SE80. Say : YRG_CONTEXT_MENU Now create a Table type node with cardinality 0:N with two attributes Id (type String) and Name ( Type String ). Goto the Main View and create a context Menu (Static_Menu) with MenuactionItems (sm1 & sm2).

Upload: rg

Post on 18-Apr-2015

72 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Context Menus Webdynpro

Context Menus in Webdynpro ABAP ->

Create a Webdynpro Component via SE80. Say : YRG_CONTEXT_MENU

Now create a Table type node with cardinality 0:N with two attributes Id (type String) and Name ( Type String ).

Goto the Main View and create a context Menu (Static_Menu) with MenuactionItems (sm1 & sm2).

Page 2: Context Menus Webdynpro

Both MenuActionItems SM1 & SM2 are having to corresponding methods associated with their actions ON_SM1 & ON_SM2.

Now Create a Table with two columns Id and Name . See the below screen shot.

Page 3: Context Menus Webdynpro

ContextMenuBehaviour and ContextMenuId must be “Provided” & “Static_Menu” for any UI element (Could be Table , RootUIelementcontainer )if we are creating static menu.

In case we are setting the context menu dynamically , then we need to go to the method WDCONTEXTMENU of the view and write the below code.menu = context_menu_manager->get_context_menu( 'STATIC_MENU' ).

Coding inside the methods of ON_SM1 & ON_SM2 is as below.method ONACTIONON_SM1 .

    DATA lo_nd_table TYPE REF TO if_wd_context_node.

    DATA lt_table TYPE wd_this->Elements_table.    DATA ls_table TYPE wd_this->Element_table.

*   navigate from <CONTEXT> to <TABLE> via lead selection    lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).

Page 4: Context Menus Webdynpro

*   @TODO handle non existant child*   IF lo_nd_table IS INITIAL.*   ENDIF.ls_table-id = '3'.ls_table-name = 'Jai'.APPEND ls_table to lt_table.clear : ls_table.

*  * @TODO compute values*  * e.g. call a model function*    lo_nd_table->bind_table( new_items = lt_table set_initial_elements = abap_true ).

endmethod.

method ONACTIONON_SM2 .

  DATA lo_nd_table TYPE REF TO if_wd_context_node.

    DATA lt_table TYPE wd_this->Elements_table.    DATA ls_table TYPE wd_this->Element_table.

*   navigate from <CONTEXT> to <TABLE> via lead selection    lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).

*   @TODO handle non existant child*   IF lo_nd_table IS INITIAL.*   ENDIF.ls_table-id = '4'.ls_table-name = 'Preetam'.APPEND ls_table to lt_table.clear : ls_table.

*  * @TODO compute values*  * e.g. call a model function*    lo_nd_table->bind_table( new_items = lt_table set_initial_elements = abap_true ).

endmethod.

Result :

Page 5: Context Menus Webdynpro
Page 6: Context Menus Webdynpro
Page 7: Context Menus Webdynpro