cancel
Showing results for 
Search instead for 
Did you mean: 

Browser (user agent) detection in web dynpro abap

jan_krohn
Active Participant
0 Kudos

Hi guys,

I've been looking for a way to capture the users' browser and os versions to store them into a table for a smoother support process. I've found a couple of solutions for WD Java, but nothing for ABAP.

So if you know anything about this, any help would be highly appreciated.

Jan

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can use the method GET_PLATFORM of class CL_GUI_FRONTEND_SERVICES to get OS version.

As for the browser, web-dynpro only supports IE, Firefox and Safari browser.

Will update you if I find a way to get browser name in ABAP.

-Manish

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Manish Kumar wrote:

Hi,

You can use the method GET_PLATFORM of class CL_GUI_FRONTEND_SERVICES to get OS version.

As for the browser, web-dynpro only supports IE, Firefox and Safari browser.

Will update you if I find a way to get browser name in ABAP.

-Manish

This is bad advice as you can't use CL_GUI_FRONTEND_SERVICES from Web Dynpro. This class uses the SAPGUI Control Framework, which of course won't be present in Web Dynpro ABAP. 

IF_WD_APPLICATION has some frontend information but mainly the remote IP Address and method GET_CLIENT_ENVIRONMENT (Portal, NWBC, etc - not Browser). More detailed information is captured by the WD Framework but not exposed up through the APIs.

jan_krohn
Active Participant
0 Kudos

Dear Thomas,

That was very helpful already, thanks! Do you know where in the framework the info is captured? So I can write it to a memory id, and have it available in the API.

Thanks a lot!

Jan

jan_krohn
Active Participant
0 Kudos

I think I found it, but must wil til Monday to test...

Function module HTTP_DISPATCH_REQUEST

http headers seem to be in c_server->request->get_header_field.

Former Member
0 Kudos

Hi,

You can get the browser details from if_http_rquest`get_header_fields.

data cl type REF TO cl_http_request.
cl ?= wdr_task=>request.

CALL METHOD CL->IF_HTTP_ENTITY~GET_HEADER_FIELDS
   CHANGING
     FIELDS = fld.

But to get the instance of the HTTP REQUEST, you need to access the attributes of

WDR_TASK class.

But the problem is technically direct access to WDR_TASK is NOT supported.  You can read this help document about usage of the programming interfaces of Web Dynpro:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/64/be5b4150b38147e10000000a1550b0/frameset.htm

So may be if you can get the instance of HTTP REQUEST from some other

RUNTME API classes then you could succeed.

jan_krohn
Active Participant
0 Kudos

Harshith,

Your reply pointed me in the right direction! The user agent can be picked up in methods EXECUTE_REQUEST and EXECUTE_REQUEST_FROM_MEMORY of class CL_HTTP_SERVER.

One of these two is always executed, so writing it to a memory id in both of them makes it available to all webdynpro applications.

It can be retrieved with the line

lv_useragent = server->request->get_header_field( 'user-agent').

Jan

TusharShinde
Active Participant
0 Kudos

Hi,

You can try with below code, no need for storing anything in memory,

DATA: lo_http_request TYPE REF TO cl_http_request.

   DATA: lt_fields TYPE  tihttpnvp.

   lo_http_request ?= wdr_task=>request.

   lo_http_request->get_header_fields(
     CHANGING
       fields = lt_fields    " Header fields
   ).

Explanation - "request" attribute in Class "WDR_TASK" is a static attribute so you can directly access it without any indirect way to access, once you get the reference to CL_HTTP_REQUEST you can simply call method
get_header_field( ) or get_header_fields( ) to get all Header Data, parameter 'user-agent' contains the desired value.

I wrote the above code in WD View init() method.

Thank You.

Br.

Tushar Shinde

Former Member
0 Kudos

hello ,

Could you please explain me how can we get the windows login id in webdynpro application.

DATA: lo_http_request TYPE REF TO cl_http_request.

    DATA: lt_fields TYPE  tihttpnvp.

    lo_http_request ?= wdr_task=>request.

    lo_http_request->get_header_fields(
      CHANGING
        fields = lt_fields    " Header fields
    ).

in lt_fileds, user_agent is not giving the my windows  login id.

it is giving : Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E)

Could you please me how can I get the windows login id in webdynpro application.