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.
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.
Provide the ID and Type for the UI element and press enter.
Enter the text property of the Button UI element as Google and create the action for the button UI element.
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.
Code will be generated as below.
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.
Coding's will be generated as below.
Replace the object reference me with the object reference for the window manager(lo_window_manager) and provide the URL exporting parameter.
Save and activate the whole component and create the application to test the component.
Step 5: Create the application as shown below.
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:
Click on the URL button. Ensure that the pop up is not blocked in the browser. Google page will be opened in new tab.
We can also call the other component from one component using the URL of that component which you will see in the next post.
0 Comments:
Post a Comment