cancel
Showing results for 
Search instead for 
Did you mean: 

Bind Menu with Table Data

Former Member
0 Kudos

Hi,

How can i bind the table data into menu in textview.

Please guide me to do this..

Regards,

Kumar L

Accepted Solutions (0)

Answers (3)

Answers (3)

uday_gubbala2
Active Contributor
0 Kudos

Hi Kumar,

Is your issue resolved? If yes then please do the needful & close this thread.

Regards,

Uday

uday_gubbala2
Active Contributor
0 Kudos

Hi Kumar,

Just created a dumb example to try paste in here. I am displaying data from SFLIGHT in my table. I want to create MenuItem's dynamically for my first columns textview. (i.e., CARRID) I have created a Menu with id "MENU1" for the textview T1_CARRID. So now I need to create corresponding MenuItems for this menu dynamically. Below is the coding with which I am filling my table (done using a supply function method) & my coding for creating the MenuItems.

Regards,

Uday

Coding to fill my table with data (supply function method):

method SUPPLY_DATA .
  data: lt_data type wd_this->elements_sflight.

  select carrid
         connid
         fldate
         price from sflight into table lt_data.
  node->bind_table( new_items = lt_data ).
endmethod.

Coding to create the MenuItem dynamically:

method WDDOMODIFYVIEW .
  check first_time = abap_true.

  data: lr_menu type ref to cl_wd_menu,
        lr_menu_item type ref to cl_wd_menu_action_item,
        lv_str type string,
        lt_carrid type standard table of sflight-carrid,
        wa_carrid type sflight-carrid.

*** Fetch few carrid values which would be used as texts while creating menu items
  select distinct carrid from sflight up to 5 rows into table lt_carrid.

*** Get the reference of the Menu created at design time. We need to add menu items to this element
  lr_menu ?= view->get_element( id = 'MENU1' ).

  loop at lt_carrid into wa_carrid.
*** Menu item expects the text to be passed to it in a string variable. So swap the variables...
    lv_str = wa_carrid.
*** Create a new instance of the MenuActionItem
    lr_menu_item = cl_wd_menu_action_item=>new_menu_action_item( ).
*** Add text to the created MenuActionItem
    lr_menu_item->set_text( value = lv_str ).
***  Finally associate the created MenuActionItem with the layout's Menu element
    lr_menu->add_item( exporting index     = sy-index
                                 the_item  = lr_menu_item ).
  endloop.
endmethod.

So now when I test my component the all textviews in the CARRID column would be having 5 menuitems created with the values as in internal table lt_carrid.

Former Member
0 Kudos

Hi Uday,

this codeing is very use full but i have to navigate to corresponding page when I click the menuactons wich was created dynamically.

and please let me know how to create the Menu from codeing itself (Not Menu actions).

Regards,

Kumar K

uday_gubbala2
Active Contributor
0 Kudos

Hi Kumar,

Can you please be a bit more clear about your requirement? You mean to say that suppose I give a menu for all the textviews in column1. Then within any of the cells of column1 the user should get a menu with all the possible values for this column?

Regards,

Uday