cancel
Showing results for 
Search instead for 
Did you mean: 

Passing URL parameters to WD application

Former Member
0 Kudos

Hi!

To pass URL parameters to WD application I currenly inbound plug 'defauld' (of type 'Startup') of main window. I use following code:


types:
    begin of param_t,
      name type string,
      value type string,
    end of param_t.
  data: params type standard table of param_t.
  data: param like line of params.

  wdevent->get_data(
    exporting
      name = '_ALL_URL_PARAMETERS'
    importing
      value = params
  ).

It works fine but this plug is called after init methods of the component controller an of the view. So if I want to do something with parameters, I must do in this plug.

Is there way to pass URL parameters in a WD app. so that they were available from the very beginning of the application work i.e. in init method of the component controller etc.?

Thanks!

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi

Thanks for your reply.

I did another work around.

- I added a inbound plug to my window and defined the parameter in it. because I could pass value to this parameter in my URL

- In the event of this O/B plug I assigned the value of this parameter to a global variable declared in component controller.

- I created a view with outbound plug and in INIT method of that view I triggered the outbound plug. ( So basically nothing was executed in this view)

- This view's outbound plug was linked to my main view where I had all my logic.

- On analyzes I found that before switching to main view the windows O/B plug event in triggered. And this event assigned the value of parameter to my global variable.

- I could access the value through global variable in my main view.

Regards,

Priya

alejandro_bindi
Active Contributor
0 Kudos

I had the same requirement too. There are a couple of threads on the subject as well, I've posted in one of them but had no answer:

The workaround i've used is this, it's definitely not as neat as I would like to since you end up having two initialization methods per controller, WDDOINIT and the one you create (for each controller you want to run code in using the received parameters). Nevertheless, it works:

1) Create an event in your component controller, for example INIT_COMPLETED.

2) Define a new method in your component controller, e.g. INIT_AFTER_WINDOW. This method receives an Importing parameter TYPE tihttpnvp. It uses this received HTTP parameters for the initialization logic and finally raises the INIT_COMPLETED event (This is the method that "replaces" WDDOINIT).

3) In the Window's Inbound plug handler, you get the HTTP parameters (with wdevent->get_data) and afterwards call the method WD_COMP_CONTROLLER->INIT_AFTER_WINDOW (maybe you need to declare the usage previously in the Window to have the reference available).

4) Finally, if you need some of the Views to be initialized afterwards the component controller's INIT_AFTER_WINDOW runs (for example to show some initialization messages), you'll have to replace the WDDOINIT method with an INIT_AFTER_COMPCTRL method and subscribe it to the component controller's INIT_COMPLETED event.

I hope you got the idea, and more importantly, that we get some cleaner solution from SAP for achieving this in the future.

Regards

Edited by: Alejandro Bindi on Nov 6, 2008 10:08 PM

INIT_AFTER_WINDOW is the method to be called on step 3

Former Member
0 Kudos

Hi,

I have similar requirement. Just wanted to check did u get any solution to your problem.

I also parameter that is attached in Inbound plug of my window. But I ant to access it in Init method of view.

Kindly let me know if you have found any solution.

Regards,

Priya

TomVanDoo
Active Contributor
0 Kudos

you can check the url parameters in the init method of the window controller.

this is before the component controller is initialised and before any view is shown

call method CL_WD_UTILITIES=>CONSTRUCT_WD_URL( exporting APPLICATION_NAME = l_name

importing OUT_LOCAL_URL = lurl ).

Former Member
0 Kudos

Hi Tom!

As I see, this method takes parameters table as input. But first it is needed to get these parameters somewhere.