cancel
Showing results for 
Search instead for 
Did you mean: 

How to change sap-language parameter at runtime

jakob_steen-petersen
Active Participant
0 Kudos

Hi

I want to create a Change Language button on an webdynpro Application. I know that the parameter is determined during url creation, but i need the to give the user the posibility of changing the language without closing the browser and logging out etc.

My idea is to us an Outbound plug assigned to lets say a Button. The plug is connected to an Inbound plug og the very same Window. So actually the Application will reload.

The action on the button is like this

data: l_language type sy-langu.
l_language = cl_wd_runtime_services=>get_url_parameter( name = 'sap-language' ).
wd_this->fire_language_plg).


Then i read the current language - i.ex: E


But of course i will need to change the parameter sap-language to the new language - lets say: K


But how?

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member184578
Active Contributor
0 Kudos

Hi,

Use Exit plug and get the WDA application url and concatenate the sap-language to the value you want to change and then pass the final url to the Exit plug.

you can refere this document: Exit plug in WDA

hope this helps,

Regards,

Kiran

jakob_steen-petersen
Active Participant
0 Kudos

Hi

Seems to be a good solution if it´s not possible just to alter the single parameter.

But then i have an additional question (could do a Google search 🙂 😞 how can i read the full url of the application?

Former Member
0 Kudos

Hi Jakob,

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

Regards,

Ashvin

former_member184578
Active Contributor
0 Kudos

Hi,

Use method CONSTRUCT_WD_URL of class CL_WD_UTILITIES and pass the Web Dynpro Component to get the complete URL.



CALL METHOD cl_wd_utilities=>construct_wd_url

     EXPORTING

       application_name = 'APPL_NAME' " your WDA appl name

     IMPORTING

       out_absolute_url = lv_url.

Now, you can concatenate language parameter to lv_url and pass this to Exit plug.

hope this helps,

Regards,

Kiran

jakob_steen-petersen
Active Participant
0 Kudos

@Nanreshsing

Well i know how to get er certain paramter - i need the FULL url.

@Kiran

The problem with that method is that i only gives me the Default url of the application. The reason why i need the actually used url, is because i have some Custom parameters in the url.

Would be nice if there was a method to just read the actual url of the call?

former_member184578
Active Contributor
0 Kudos

Hi,

As far I know, there is no way to get the current url in browser. Alternately, you can get the url parameters and then construct the url with the parameters.

write the below code in HANDLEDEFAULT method of Window:


DATA: lt_parameters TYPE tihttpnvp.

*Get URL params

  Wdevent->get_data(

  EXPORTING name = if_wd_application=>all_url_parameters

  IMPORTING value = lt_parameters ).

*Construct URL

CALL METHOD cl_wd_utilities=>construct_wd_url

     EXPORTING

       application_name = 'APPL_NAME' " your appl name

       it_parameters    = lt_parameters  " to this params itself you can append the sap-language

     IMPORTING

       out_absolute_url = lv_url.

you may refer this document:

Regards,

Kiran

Former Member
0 Kudos

Hey Jakob,

I found the discussion on scn where this has already been answered (For full url):

Regards,

Ashvin

jakob_steen-petersen
Active Participant
0 Kudos

Hi

Yes it´s a solution - but gives me a need to Hardcode something. Your solution would do allright when you are on the Inside of the Company-Network. But if you will allow the users to call the application from the outside world using a public domain it´s not good:

The proposed solution will create an url like this http://sapserver.locdom.local:8000/sap/bc/webdy......

But in my case the url called are: http://app.company.com/sap/bc/webdy...

And even more different if we set up an Alias in SICF.

So i will have to hardcode these server names. Again it would have been much easier if one could just ask the Application: hi - which url have you called me with?

former_member184578
Active Contributor
0 Kudos

Hi,

There is no other way. There is an internal API which builds the URL, and you can get the public domain by reading the table WDR_TASK=>CLIENT_WINDOW->IF_WDR_CLIENT_INFO_OBJECT~HEADER_FIELDS with key name = 'host'.

But this is an internal api and should not be used, SAP may change it at any time and if it works use it at your own risk considering the future effects.

Regards,

Kiran