sapdev logo background
sapdev logo sapdev logo

Get the name of the button the user has clicked on within the SAP web dynpro action ABAP code

To get the button name you simply need to interrogate the WDEVENT parameter. The ABAP code to do this is very simple and can be seen below, but before you dive in and implement this I just want to show you what the values for this parameter look like within the ABAP debugger. This will hopefully help to explain it better and also show you how to access data from other similar class/method variables.

While debugging the ACTION method code you will be able to enter 'WDEVENT->PARAMETERS[1]-VALUE' into the variable field to access the button name.

You will first see that it is a table made up of 2 fields, NAME and VALUE. You will also see that this table has 2 entries, one of which has the name as 'ID' and the value as the name of your button. This is where the name of your button is stored and what you want to retrieve.

Now to the actual ABAP code which simply retrieves this value, notice the parameter name and value being passed to the method get_string.

  data ld_butname type string.
  ld_butname = wdevent->get_string( name = 'ID' ).

  case ld_butname.
    when 'BUT'.

To get the method name 'get_string' you would simply double click on the type associated with WDEVENT to access the class details ( i.e. CL_WD_CUSTOM_EVENT ). You will also notice that other options are available within this class for performing this particular functionality such as 'get_data' etc.

comments powered by Disqus