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

Reading application parameter from portal

In this blog we will learn how to read the application parameter from the portal. Let us see how to read a parameter from the URL in an already created component.

Let’s see how to read the user who is logging into the portal and triggering the link for our application.

Pre-requisites: The portal must be configured in a way to pass the parameter.

Step 1:
Go to the window of the component and select the method handle default. This is the first method which is triggered when a component load, even before the DOINIT method.

clip_image001

Step 2:
In Handle default method create a importing parameter to get the value from the portal the importing parameter must be created in a same name that the portal passes the parameter.

clip_image002

Step 3:
Go to the application. In parameters tab add the variable declared in Handle default method using F4 help.

clip_image003

Step 4:
Whatever the value that comes in the portal will be captured by the parameter we declared. It can be used only within the windows, to use that variable in our view we have to move it to the controller.
To move it to the controller, create a variable in the component controller as shown below.

clip_image004

Step 5:
Now move the application parameter to the variable declared in the component controller.
Wd_component_controller is the object referring to the component controller.
Using that object access the attribute of the component controller and assign the importing parameter of the handle default method to it. Now value is passed from window to the controller.

clip_image005

Step 6:
Now we have to set the value in some variable so that the value can be used across any no’s of views.
Create a node in the component controller with an attribute to hold the value.

clip_image006

Step 7:
Handle default method is executed after the method wddoinit. Hence we can make use of method wddomodifyview to set the value to the context node.

clip_image007

Code:

method wddomodifyview .

 
data : lv_user type uname.
 
data lo_nd_uname type ref to if_wd_context_node.
 
data lo_el_uname type ref to if_wd_context_element.
 
data ls_uname type wd_this->element_uname.

* Move the value from component controller attribute to the variable.
  lv_user
= wd_comp_controller->lv_user.
 
* set the value to the context node.
* navigate from to via lead selection
  lo_nd_uname
= wd_context->get_child_node( name = wd_this->wdctx_uname ).
* get element via lead selection
  lo_el_uname
= lo_nd_uname->get_element( ).
* set single attribute
  lo_el_uname
->set_attribute(
  name
= `LV_USER`
 
value = lv_user ).

endmethod.                    "WDDOMODIFYVIEW

Now Parameter has been set in the context node and can be accessed in any number of views.

About Arun

4 Comments:

  1. We can also read the application parameter using the class

    wdr_task=>client_window->get_parameter( 'i_parameter' ).

    ReplyDelete
    Replies
    1. Please, explain how to read application parameters from WDDOINIT method of component controller.

      in 1st step, you told that handledefault method triggers first but in 7th step you told differently.

      please clarify brother!.

      Delete
    2. i learnt webdynpro from your website........thank you very much brother!

      Delete
  2. They ought to be simple in correspondence and you can contact by messages, live visits, moment errand people and by global calling framework. Outsourcing organizations give every one of these offices to their designers.
    convert website to app

    ReplyDelete

Powered by Blogger.