Skip to Content
avatar image
Former Member

Creating Dynamic action handler for dynamic buttons

Hi Experts,

My requirement is based on the select query , I am getting 'n' number of records in my internal table and now I need to create that 'n' number of Buttons dynamically in my Webdynpro Layout and also create same number of dynamic Action Handlers to assign the same to those dynamically created buttons.

So please let me know can we create dynamic action handlers in the code itself rather than creating manually in the view controller or component controller.


Vishal Chauhan

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Sep 03, 2012 at 08:45 AM

    Hi Vishal,

    I think is not possible to create the action handler dinamically.
    You can create one generic method for all your buttons and modify the logic in the code depending on the name of the button you can get from the parameter WDEVENT.


    Add comment
    10|10000 characters needed characters exceeded

    • Former Member srinivas sana

      Hi Srinivas,

      Thanks for your reply. It works .

      Can you please let me know , same way can we findout the Text of the button through any parameter.


      Vishal Chauhan

  • Sep 03, 2012 at 01:26 PM

    Hi Vishal,

    I don't think you need to create the buttons or actions dynamically. If I understand your requirement, you want to display one button for each row of your internal table.

    In your view layout, create a TableColumn that contains a button and assign the button an onAction event. When you create the action for the button, select the option "Transfer UI Event Parameters" from the wizard dialog. Selecting this option gives you two additional importing parameters in your method signature, one of which is CONTEXT_ELEMENT. The parameter CONTEXT_ELEMENT tells you in which row of the internal table the button was clicked.

    If you have already created the action and its handler method, you can manually add the CONTEXT_ELEMENT importing parameter to the method signature. Use type ref to IF_WD_CONTEXT_ELEMENT.

    You can also programmatically read the context element from WDEVENT with the statement,

    wdevent->get_context_element( name = 'CONTEXT_ELEMENT' )



    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Amy,

      I have created buttons dynamically , but now I want to get the ID of the button which user pressed in my variable toperform further process. I am getting the Button ID through WDEVENT Parametre but in the form of Hashed Internal table of Ref type CL_WD_CUSTOM_EVENT , So I am not able to get that ID in my string variable.

      So can you please help me out on this.


      Vishal Chauhan

  • Sep 20, 2012 at 11:30 AM

    Create just one action for all your buttons. At runtime when you're creating the buttons, you can add any additionaldata (despite from an ID) using the method MAP_ON_ACTION.


        lt_params type wdr_name_value_list

      , ls_param type wdr_name_value


    ls_param-name = 'ANY_NAME'.

    ls_param-value = 'YOUR_VALUE'.

    append ls_param to lt_params.

    lo_button->map_on_action( lt_params ).

    In your action, you can access these parameters again.

    lv_your_value = wdevent->get_string( 'ANY_NAME' ).

    Add comment
    10|10000 characters needed characters exceeded