cancel
Showing results for 
Search instead for 
Did you mean: 

Determine whether Web Dynpro running under SAP GUI or Web Browser

Former Member
0 Kudos

Hi all,

inside my Web Dynpro component I need to determine whether it is running under SAP GUI (ie. via a WDYID parameter transaction), or running under a web browser (eg. Internet Explorer).

I can not see anything in the program call stack or SYST system fields that I could use to determine this.

Does anyone have any suggestions ?

Thanks,

Grogan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Glen - brilliant ! Thanks.

Thomas - I retrieve all URL parameters in the startup inbound plug using WDEVENT->GET_DATA, but parameter sap-wd-sapgui is not available. I tried adding sap-wd-sapgui as a parameter to the inbound plug, but it complains saying that hyphens in the name are invalid.

Is there another way to get this parameter, or is Glen's method the only way ?

Thanks,

Grogan

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

It should be a URL parameter like any other, but I wonder if the WD runtime strips out the sap-wd-* parameters to keep them from being confusing to application developers. Come to think of it, I've never stopped to think aobut but you dont' see the sap-client or sap-langu parameters either.

Actually I just found the code where these are filtered out for inboud plug parameters:

if <url_param>-name np 'sap-*' and
         <url_param>-name np 'sap.*' and
*        <url_param>-name ns '~' and
         <url_param>-name np 'wd*'.

I suppose the wdr_task=>client_window might be the only access. There is a wdr_task=>client_window->CLIENT_ENVIRONMENT that looks like it would work instead of reading the parameter. It appears to get set with values from the constant value set e_client_environment. There is a SAPGUI entery with value 3.

WDR_TASK is pretty low level however. It gives you access to the REQUEST and RESPONSE object - and the complete set of URL parameters and HTTP headers as well. Potentially dangerous stuff as Web Dynpro goes.

But a little searching may have lead us around to the correct way to access this. There is a method of IF_WD_APPLICATION called GET_CLIENT_ENVIRONMENT. This would appear to the public API for the WDR_TASK access. You can read the online help for it here:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/43/036b1fdc7e22f2e10000000a1553f7/frameset.htm

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks gents,

this is now working a treat.

Here is my final code in the Component Controller method WDDOINIT:


DATA lr_api                       TYPE REF TO if_wd_component.
DATA lr_application               TYPE REF TO if_wd_application.

* Get component API.
  lr_api = wd_this->wd_get_api( ).

* Get the application.
  lr_application = lr_api->get_application( ).

* Determine if called from SAP GUI.
  IF lr_application->get_client_environment( ) EQ
           if_wd_application=>co_client_environment-sapgui.
*   Web Dynpro was called from SAP GUI.
  ENDIF.

Regards,

Grogan

Former Member
0 Kudos

Hi Grogan

Try the following:

data lv_insapgui type string.
lv_insapgui = wdr_task=>client_window->get_parameter( `sap-wd-sapgui` ).

It can be run almost anywhere but the most likely places to put it are either in the handler for your window's default inbound plug or in the WDDOINIT of your component controller.

Regards

Glen

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You are correct - the WDYID transaction already does set a parameter if running in place within the SAPGUI. Look at WDY_CONSTRUCT_URL, line 39. I wouldn't necessarily suggest using wdr_task=>client_window->get_parameter however. That's an internal API. However you should be able to read this parameter in the input plug, like any other URL parameter.

Former Member
0 Kudos

Thank you for the replies.

I have confirmed that SY-PFKEY is blank when called from both the SAP GUI and web browser, so no joy there.

Thomas, can you elaborate on your suggestion "passing a URL parameter into the Web Dynpro when calling it from WDYID" ?

I have added a URL parameter named FROMSAPGUI to the Application and the handler method of the startup inbound plug with an initial (blank) default value. The URL can then be used to trigger the application in a web browser while specifying a different value for the FROMSAPGUI parameter (but this is the reverse of what I want).

Transaction WDYID has only 4 possible parameters, and none of these seem to allow passing an application specific value. So my issue now is: how to have my WDYID parameter transaction specify a value for the custom FROMSAPGUI URL parameter ?

The only other thought I had was to create two separate Applications for my Component - one for use by SAP GUI / WDYID, and one for use by web browsers, but I would rather avoid this if possible.

Thanks & regards,

Grogan

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You are correct. Although the inner function module sof WDY_PRGN_NODES does have the functionality to parse in URL parameters; this isn't exposed via WDYID. So you have two choices. You can do as you already thought, and create two different Web Dynpro Applications. Or you can clone WDYID (or use the enhancement framework) and modify it to set a URL parameter when it builds the WDA URL.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The problem is that that Web Dynpro application is running a browser in either case. WDYID just puts an HTML Container Control on the screen. It is still a web browser running in that HTML Container Control. The call stack and system variables will be the same in either case. The only thing I would suggest is passing a URL parameter into the Web Dynpro when calling it from WDYID.

abhimanyu_lagishetti7
Active Contributor
0 Kudos

try SY-PFKEY , it is initial when run from browser

Abhi