Hi, I provide training in SAP UI5. Also feel free to checkout my new web page https://saptechblog.com
Webdynpro ABAP

Calling a Web URL

 

In this post we will study how to call an web URL from an webdynpro component. In this tutorial we will place the button UI element and on the click of the button UI element we will call the Google home page.

 

Step 1: Go to the Tcode SE80 and create a webdynpro component as shown below.

 

clip_image002

 

Assign the component to a package or save it in the local object.

 

Step 2:  In the layout tab of the view controller, create  a button UI element as shown below.

 

Right click on the Root container UI element and select insert UI element.

 

clip_image004

 

 

Provide the ID and Type for the UI element and press enter.

 

clip_image006

 

Enter the text property of the Button UI element as Google and create the action for the button UI element.

 

clip_image007

 

 

Step 3: In the event handler method for the Button UI element do the following to call the URL.

 

Generated the coding  using the code wizard.

 

clip_image009

 

Code will be generated as below.

 

clip_image011

 

Instead of calling the method create_window call the method create_external_window to call the external URL.

 


Step 4: Using pattern call the create external window of the interface if_wd_window_manager.

 

clip_image013

 

Coding's will be generated as below.

 

clip_image015

 

Replace the object reference me with the object reference for the window manager(lo_window_manager) and provide the URL exporting parameter.

 

clip_image017

 

 

 

Save and activate the whole component and create the application to test the component.

 

 

Step 5: Create the application as shown below.

 

clip_image019

 

 

Test the application.

 

 

Coding's in the method for Button UI element.

 

DATA lo_window_manager TYPE REF TO if_wd_window_manager.
DATA lo_api_component  TYPE REF TO
if_wd_component.
DATA lo_window         TYPE REF TO
if_wd_window.

lo_api_component  = wd_comp_controller->wd_get_api( ).
lo_window_manager = lo_api_component->get_window_manager( ).


CALL METHOD
lo_window_manager->create_external_window
 
EXPORTING

    url            =
'http://www.google.com'
    modal          = ABAP_FALSE
    has_menubar    = ABAP_TRUE
    is_resizable   = ABAP_TRUE
    has_scrollbars = ABAP_TRUE
    has_statusbar  = ABAP_TRUE
    has_toolbar    = ABAP_TRUE
    has_location   = ABAP_TRUE
  receiving
   
window        
= lo_window
    .


lo_window->open( ).

 

 

Output:

 

clip_image021

 

Click on the URL button. Ensure that the pop up is not blocked in the browser. Google page will be opened in new tab.

 

clip_image023

 

We can also call the other component from one component using the URL of that component which you will see in the next post.

 

About Arun

0 Comments:

Post a Comment

Powered by Blogger.