cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic programming - how to set parameter for an action ?

matteo_montalto
Contributor
0 Kudos

Hi experts,

I'm developing a part of code which dynamically generates a button and set an ON_ACTION clause to bind it to an action:

  bd_toolbutton_edit = cl_wd_toolbar_button=>new_toolbar_button( text = 'Edit' on_action = 'EDIT_DATA' ).

Problem: I could have many buttons on my WD application and I'd like to code just one ONACTIONEDIT_DATA method to manage them all.


In order to do so, I'd like to receive an ID as parameter in the method ONACTIONEDIT_DATA so that my method "knows" which button has been pressed.

I don't know anyway how to pass that parameter to the action since it is all made via dynamic programming.

Thanks


Accepted Solutions (1)

Accepted Solutions (1)

UweFetzer_se38
Active Contributor
0 Kudos

Hi Matteo,

the method new_toolbar_button already has a parameter called "ID".

In the action you should be able to get the ID with

READ TABLE wdevent->parameters
     ASSIGNING <ls_parameter>
     WITH KEY name = 'ID'.

matteo_montalto
Contributor
0 Kudos

Yes Uwe, that was the trick.... I forgot passing the ID (optional) parameter on the constructor, once set it was easy to retrieve it directly in the method.

Thanks again!

Answers (1)

Answers (1)

former_member184578
Active Contributor
0 Kudos

Hi,

Problem: I could have many buttons on my WD application and I'd like to code just one ONACTIONEDIT_DATA method to manage them all.

I just seek a small clarification, How you are going to handle all the buttons in ONACTIONEDIT_DATA method. Because as this is an event handler it will be called when you click on edit button and not for other buttons isn't it?

If you are creating a generic method to handle all the buttons, you can create actions for all the buttons and get the button action which is clicked using the below code:

   data lo_api_controller type ref to if_wd_view_controller.

    data lo_action         type ref to if_wd_action.

    lo_api_controller = wd_this->wd_get_api( ).

    lo_action = lo_api_controller->get_current_action( ).

  

     lo_action->name   contains the action name of clicked button .


Regards,

Kiran