cancel
Showing results for 
Search instead for 
Did you mean: 

Create action at runtime

Former Member
0 Kudos

Hello,

I am not sure if this is possible, but I would like to know if an action can be created at runtime, or on the contrary it must be defined in the 'Actions' tab.

Best regards

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello,

but I want to create an action not for a button but to be used in a context menu, so I think your solution doesn't work for me.

I am almost sure that it cannot be done, but just to see if anybody else had the same problem in the past.

Best regards,

Javi

Former Member
0 Kudos

Hi javier,

Yes you can create action at runtime...

Write below code in WDDOMODIFY method..

DATA: lr_container TYPE REF TO cl_wd_uielement_container,
        lr_button TYPE REF TO cl_wd_button. 
  CHECK first_time = abap_true.
  lr_container ?= view->get_element( id = 'ROOTUIELEMENTCONTAINER' ).
  cl_wd_matrix_layout=>new_matrix_layout( container = lr_container ). 
 
  lr_button = cl_wd_button=>new_button( id         = 'BUTTON'
                                        text       = 'My Button!'
                                        on_action  = 'ACTION' ). 
 
  cl_wd_matrix_head_data=>new_matrix_head_data( element = lr_button ). 
  lr_container->add_child( the_child = lr_button ).

Create an action by name ACTION under the "Actions" tab of your component.

cheers,

Kris.

former_member184578
Active Contributor
0 Kudos

Hi.,

check this tutorial by thomas sir: [Dynamic Context, Mapping , Binding|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/201ddd3b-b4ce-2b10-8883-880ae8147f89]

this helps u.,

also check this wiki: http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=141263105

Thanks & Regards,

Kiran