There are three different ways to transfer data from Main component to sub-component in web Dynpro. They are,
v Interface Node in Component Controller
v Assistance class attribute
v 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,
Create the Main Web Dynpro component, and select Sub component as used component as shown below,
In the Main Web Dynpro component controller select context tab, Click “Controller Usage” and select “Sub_Comp”.
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,
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.
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 ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 |