Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

We can read the URL parameters in the following ways. 

If we have one or two parameters attached to URL then simply we can declare those parameters in the interface of window method HANDLEDEFAULT from there directly we can access the values.Please find the screen shot below for the same.

Sample URL: http://newdomain.abc.com:8000/sap/bc/webdynpro/sap/zwda_url_parameters?pernr=12345&name=test1&sap-client=200&sap-language=EN



If we have more parameters or repeated parameters with values in the URL like below.

Eg URL: http://newdomain.xyz.com:8000/sap/bc/webdynpro/sap/zwda_url_parametersl?pernr=102526&name=test1&pernr=132456&name=test2&penr=46786&name=test3&sap-client=200&sap-language=EN  

In the above URL we have repeated parametes with values to read them follow the code below.

METHOD handledefault .
*--Declaration to hold values of parameters
  TYPES:begin of ty_values,
      pernr type persno,          " Eemployee number
     name type pad_cname,   " Employee name
  end of ty_values,
 ty_t_param_val  type standard table of ty_values.
*--Field symbols   
  FIELD-SYMBOLS: 
     <fs_data> TYPE tihttpnvp, 
     <ls_data> TYPE ihttpnvp.
  DATA:
      ls_value type ty_values,
     lt_values type ty_t_param_val,
   ls_parameter like line of wd_event->parameters.

We have an attribute PARAMETERS in the class CL_WD_CUSTOM_EVENT which holds all the parameters of the URL during runtime.

*--To read all URL parameters
read table wd_event->parameters into ls_parameter with key name = if_wd_application=>all_url_parameters.
if sy-subrc eq 0.
*--Assign parameters to internal table(name &value )
 assign ls_parameter->* to <fs_data>.
loop at <fs_data> assigning <ls_data>.
if <ls_data>-name = 'PERNR'.
 ls_value-pernr = <ls_data>-value.
elseif <ls_data>-name = 'NAME'.
 ls_value-name = <ls_data>-value.
endif.
append ls_value to lt_values.
endloop.
endif.
ENDMETHOD.




 


 

2 Comments

  1. Guest

    Hi,

    Regarding this article, how can I read the standard WD parameters? Example: WDTHEMEROOT.

    Thanks.

  2. Guest

    You can get url parameters from cl_wd_runtime_services=>get_url_parameter( ).

    HANDLEDEFAULT doesn't work in all cases because this method is called after the view/controller wddoinit methods.

    -- Venky