cancel
Showing results for 
Search instead for 
Did you mean: 

How to get URL currently shown in Webbrowser

Former Member
0 Kudos

Hello,

does anyone know how to get the URL, which is currently show in Webbrowser, in my WebDynpro Application.

For Example the following URL

http://www.test.com/xy/webdynpro/test?sap-client=100&sap-language=DE

points at

http://10.170.1.99/xy/webdynpro/test?sap-client=100&sap-language=DE

I want to get following URL in my WebDynpro Apllication (and not the internal URL):

http://www.test.com/xy/webdynpro/test?sap-client=100&sap-language=DE

Thanks in advance.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

You can get the URL by giving the WD4A application name as below:

DATA lv_url TYPE string.

DATA: lt_parameters TYPE tihttpnvp,

ls_parameters TYPE ihttpnvp,

application_name TYPE string.

  • Set Application Name

application_name ='ZTEST_SAN3'.

cl_hrrcf_wd_services=>construct_wd_url(

EXPORTING

iv_application_name = application_name

it_parameters = lt_parameters

RECEIVING

rv_url = lv_url ).

Hope it helps you.

alejiandro_sensejl
Active Participant
0 Kudos

Hello SANKET SETHI,

unfortunately this doesn't work. As the name of the method states, the returned URL is constructed and not directly read from the browser. This is (to put it simple) just a concatenation of several system parameters (e.g. icm/host_name_full).

My problem is that our company exposes some applications to the outside via our firewall. So the application is reached from within our intranet (Let's stick to Krisztian's example above...) by http://10.170.1.99/xy/webdynpro/test?sap-client=100&sap-language=DE. Now we have a redirect that allows the usage of the application by our external employees from the internet by http://www.test.com/xy/webdynpro/test?sap-client=100&sap-language=DE. Method cl_hrrcf_wd_services=>construct_wd_url always returns the internal URL.

At last some additional information: With help of Flash Island technology we have used the Google Maps API, but it looks like the external application can't be started with the same Google Maps API Key as the internal application (confirmed by debugging). So we want a customizing table to allow the determination of the correct API key.

Hope I could clarify my / our problem.

Regards,

Alej

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I don't know of any public API that would give you the URL as it is typed in the browser. HOwever you can use the IF_WD_APPLICATION API to read the IP Address of the client (GET_REMOTE_ADDRESS):

http://help.sap.com/saphelp_nw70ehp2/helpdata/en/49/2fd8d1d54014cfe10000000a42189b/frameset.htm

You could perform some logic to check for the IP Address ranges of your local network and separate those from the outside and assume the different Google Maps API key for either.

Former Member
0 Kudos

Hi,

For the test You can create a node URL -> with an attribute URL (String).




  DATA: lt_parameters TYPE tihttpnvp,
        ls_parameters TYPE ihttpnvp.
  DATA lo_nd_url TYPE REF TO if_wd_context_node.
  DATA lo_el_url TYPE REF TO if_wd_context_element.
  
  DATA ls_url TYPE wd_this->element_url.

  lo_nd_url = wd_context->get_child_node( name = wd_this->wdctx_url ).
  lo_el_url = lo_nd_url->get_element( ).


********************************************** Retreive the URL parameters
  wdevent->get_data(

  EXPORTING name = if_wd_application=>all_url_parameters

  IMPORTING value = lt_parameters ).


********************************************** URL to String
  cl_hrrcf_wd_services=>construct_wd_url(
  EXPORTING
  iv_application_name = 'NAME_WD_APPLICATION'
  it_parameters = lt_parameters
  RECEIVING
  rv_url = ls_url-url ).
  lo_el_url->set_static_attributes(
     static_attributes = ls_url ).

B-Regards

alejiandro_sensejl
Active Participant
0 Kudos

Hi Thomas!

I can't believe it! We already started to build customizing like you suggested and even have evaluated most of the respective IP-ranges for all our domains and subdomains.

Yesterday I started the development of a prototype application. I don't know why but somehow (I'm so sure that was a divine intervention!) there appeared a break-point IN method if_wd_application~get_remote_address you mentioned above and I got a look on the following coding:

  method if_wd_application~get_remote_address.

    data: wa type wdr_name_value.
    read table me->application->client_window->client_info_object->header_fields into wa
               with key name = '~remote_addr'.
    if sy-subrc = 0.
      result = wa-value.
    endif.

  endmethod.                    "if_wd_application~get_remote_address

From here on I got a little curious that the http header is available from within the webdynpro. Soon afterwards I found out that the header fields are generally available in the via static attributes of CL_WDR_TASK and can be accessed fairly easy from cl_wdr_task=>client_window->if_wdr_client_info_object~header_fields.

To conclude my journey I am proud to announce that the real domain that called the webdynpro application can be accessed by reading the record of name HOST from the header_fields. This is enough for feeding e.g. a google maps call.

Up to now this worked out for all of our test cases. Would be great if you could check this out from your side and give a little response if you think that's a practical solution or it's just a coincidence how great this is working for us.

Thanks in advance and best regards,

Alej

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

CL_WDR_TASK and CLIENT_WINDOW are not public APIs. That is why they are always wrapped (such as the case with IF_WD_APPLICATION~GET_REMOTE_ADDRESS). Technically SAP won't support direct access to these objects and could change such access or the information they store at any time. If this works for you - that's good - but keep in mind that you do have some future risk here.

Former Member
0 Kudos

Hi,

You can use function module TH_GET_VIRT_HOST_DATA. Just pass the protocol value and virt_idx as 0.

Possible protocol values are

CONSTANTS: TH_PLUGIN_PROTOCOL_NONE TYPE I VALUE -1,

TH_PLUGIN_PROTOCOL_HTTP TYPE I VALUE 1,

TH_PLUGIN_PROTOCOL_HTTPS TYPE I VALUE 2,

TH_PLUGIN_PROTOCOL_NNTP TYPE I VALUE 3,

TH_PLUGIN_PROTOCOL_SMTP TYPE I VALUE 4,

TH_PLUGIN_PROTOCOL_FTP TYPE I VALUE 5,

TH_PLUGIN_PROTOCOL_MONITOR TYPE I VALUE 6,

TH_PLUGIN_PROTOCOL_SAPHTTP TYPE I VALUE 9,

TH_PLUGIN_PROTOCOL_SAPHTTPS TYPE I VALUE 10,

TH_PLUGIN_PROTOCOL_SAPSMTP TYPE I VALUE 11.

In most of the cases it is 1 (http protocol)

Regards

Vishal kapoor

Former Member
0 Kudos

Hi,

FM "TH_GET_VIRT_HOST_DATA" isn't suitable for my case. Also returns the internal URL of my WebDynpro Application and not the URL shown in Browser (which points on my WebDynpro Application).

alejiandro_sensejl
Active Participant
0 Kudos

Hello Krisztian,

I have the same problem.

Did you (or anyone else) come to a solution for this?

Thanks in advance,

Alej

Former Member
0 Kudos

hello,

One can see the url in se80. In the webdynpro explorer,enter your object name and on the web dynpro applications tab find the administrative data. It has the url that you are looking for.