cancel
Showing results for 
Search instead for 
Did you mean: 

Pass URL parameters from WD to BSP via Post

Former Member
0 Kudos

Is there a way to Post URL parameters in WD so that a BSP can retrieve them using get_form_field?

I am currently passing the required parameters from an event handler within my WD application to the BSP as part of the URL string, similar to below:

/companysys/fw_main/main_mvc.do?PARAM_1=XXXXX&PARAM_2=YYYYY&sap-client=270

The above works fine. But how to Post the params so they can still be retieved in the BSP...?

Thanks in advance!

fyi... I added a PARAMS table to the outbound plug and fired it as below, but the paramscould not be read in the BSP:

wd_this->fire_to_exit_plg( url = l_url close_window = close_window PARAMS = LT_PARAMS ).

Accepted Solutions (1)

Accepted Solutions (1)

frank_stdle
Participant
0 Kudos

Hi Frederic,

you can POST parameters to the URL of your BSP using the following code:



DATA: lo_client TYPE REF TO if_http_client,
      lv_url TYPE string VALUE 'http://mysapserver.net:8021/sap/bsp/mybsp'.

CALL METHOD cl_http_client=>create_internal
  IMPORTING
    client = lo_client.

cl_http_utility=>set_request_uri( request  = lo_client->request
                                  uri      = lv_url ).
lo_client->request->set_header_field( name  = '~request_method'
                                      value = 'POST' ).
lo_client->request->set_form_field( EXPORTING name  = 'myfield'
                                              value = 'myvalue' ).
lo_client->send( ).

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank you Frank! This accomplished exactly what I asked. Points awarded!

However...

What is bugging me now is the fact that the BSP app is processed on the lo_client->send( ) and my POSTed parameters are visible, but the BSP is not displayed. Then, when I actually Fire my WD outbound plug to display the BSP, the BSP is processed and displayed, but the POSTed parameters have been lost...

Your thoughts?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Thank you Frank! This accomplished exactly what I asked. Points awarded!

>

> However...

>

> What is bugging me now is the fact that the BSP app is processed on the lo_client->send( ) and my POSTed parameters are visible, but the BSP is not displayed. Then, when I actually Fire my WD outbound plug to display the BSP, the BSP is processed and displayed, but the POSTed parameters have been lost...

>

> Your thoughts?

That is because there are two very different calls to the BSP application occuring. The solution that you said worked is using the HTTP Client (browser if you will) of the application server. Therefore it is the ABAP system itself that is calling the BSP application. That is why nothing is displayed on the client side - because the server itself is making the request and receiving the response. This approach is really only usable if you need to call a data service (REST based or something like that), not if you actually need to dispaly the response to the user.

When you fire the navigation plug, it is the browser on the client machine that is making the request to the BSP application. This is completely separate from the request made from the application server in the previous step.

If you can't use GET and URL parameters, then you should just consider using Server Cookies. I don't think that hte HTTP Client class approach is going to get you what you want.

frank_stdle
Participant
0 Kudos

As Thomas suggests, you are not able to display your BSP using this method. Do you really need to POST data to the BSP, can you not just share data via a SAP table? Alternatively, if you absolutely want to POST, you could perhaps create an IFrame in your WDA and load a web page inside the IFrame which does a POST to the BSP. The BSP would then display inside the IFrame in your WDA. This is not a great solution though, since he iFrame UI element is deprecated.

ChrisPaine
Active Contributor
0 Kudos

Hi Fredrick,

Am I understanding correctly, that a URL of the format:

> /companysys/fw_main/main_mvc.do?PARAM_1=XXXXX&PARAM_2=YYYYY&sap-client=270

works correctly?

if so then just build the parameters into the URL string that you give to the exit plug - would that not work?

Cheers,

Chris

TomVanDoo
Active Contributor
0 Kudos

passing them via the URL is the GET method of passing parameters.

using the post method from wd to bsp is not possible I'm afraid.

You could however try to work with server side cookies, for which I refer to my colleagues blog

/people/koen.labie2/blog/2006/11/29/eating-cookies-with-webdynpro-and-bsp