Skip to Content
Author's profile photo Manigandan Damodharan

Ways to transfer value from Main to Sub Component

There are three different ways to transfer data from Main component to sub-component in web Dynpro. They are,

Interface Node in Component Controller

Assistance class attribute

ABAP code

Interface Node in Component Controller:

Create a node in Sub Web Dynpro Component controller and check the interface node property then system will automatically append interface symbol in front of the node as shown below,

/wp-content/uploads/2013/05/1_218463.png

Create the Main Web Dynpro component, and select Sub component as used component as shown below,

/wp-content/uploads/2013/05/2_218459.png

In the Main Web Dynpro component controller select context tab, Click “Controller Usage” and select “Sub_Comp”.

/wp-content/uploads/2013/05/3_218460.png

Sub Component controller context interface nodes will be available in right side of the context tab, so user can able to map the node from used component. As shown below,

/wp-content/uploads/2013/05/4_218461.png

By this way user can transfer data from Main component to Sub-Component and vice versa.

Assistance class attributes:

Create an Assistance class common to both main and sub component. In that class, Create a static attribute so that it can be used in both the component. If the data populated in Main Component it will be available in Sub Component and Vice versa.

/wp-content/uploads/2013/05/5_218462.png

ABAP Code used to retrieve data from Main Component:

User can able to get node data from Main web Dynpro component controller to sub component controller without interface node by using below ABAP logic.

  DATA:   lo_delega      TYPE REF TO cl_wdr_delegating_component.

  lo_clnt_comp TYPE REF TO cl_wdr_client_component.
  
           lo_context     TYPE REF TO if_wd_context.
  
           lo_node         TYPE REF TO if_wd_context_node.
       
      lo_element     TYPE REF TO if_wd_context_element.
 
            lv_id               TYPE char7.

  lo_delega ?= wd_comp_controller->wd_get_api( ).
 
CHECK lo_delega IS NOT INITIAL.
  lo_clnt_comp ?= lo_delega->get_window_manager( ).
 
CHECK lo_clnt_comp IS NOT INITIAL.
  lo_context ?= lo_clnt_comp->parent->component.
 
CHECK lo_context IS NOT INITIAL.
 

  lo_node = lo_context->root_node->get_child_node( name = ‘USER_ID’ ).

  lo_element = lo_node->get_element( ).

  lo_element->get_attribute(

             EXPORTING

  name =  `ID`  

IMPORTING

  value = l_id ).

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Good Informative document!!!!