cancel
Showing results for 
Search instead for 
Did you mean: 

getting data in mapped context node

Former Member
0 Kudos

Hi

I have two web dynpro components: zwd_parent having context node parent_data and zwd_child having context node child_data. i declared to usage of zwd_child into zwd_parent.

Now as we do mapping of nodes in WD ALV creation(reverse mapping). similar mapping of nodes i have done here. node parent_data is having attributes a and b. and zwd_child is not having any attribute.

I mapped zwd_parent node to zwd_child node.

now in child component I want to get the data passed through mapping of parent_data to child_data.

I used this code:

DATA lo_nd_data TYPE REF TO if_wd_context_node.

DATA lo_el_data TYPE REF TO if_wd_context_element.

  • navigate from <CONTEXT> to <DATA> via lead selection

lo_nd_data = wd_context->get_child_node( name = wd_this->wdctx_data ).

  • @TODO handle not set lead selection

IF lo_nd_data IS not INITIAL.

data:

lr_node_info TYPE REF TO if_wd_context_node_info,

attrib_info type WDR_CONTEXT_ATTR_INFO_MAP.

lr_node_info = lo_nd_data->get_node_info( ).

CALL METHOD lr_node_info->get_attributes

receiving

attributes = attrib_info

.

it is returning the mapped attribute info but data is not available.. how to get data ?

Thanks

Vishal kapoor

Accepted Solutions (0)

Answers (3)

Answers (3)

arjun_thakur
Active Contributor
0 Kudos

Hi Vishal,

Check the InputElement(Ext). property of the child node i.e zwd_child node. Use code wizard to get the values from this node.

Regards

Arjun

Former Member
0 Kudos

That i have done friend

But If I am reading attributes from code wizard I need to supply the attribute name or structure of context node. My child component is reusable so i need mapped node details at run time because parent component is not fix.

Thanks

Vishal Kapoor

pranav_nagpal2
Contributor
0 Kudos

Hi,

you can get the same code by clicking on the button code wizard in your SAP..... (button with a yellow tourch like image).. just click on that button a screen will come in that screen select read context and using f4 help select your attribute and click on ok.... you will get the similar code with value in importing parameter.. here in my code value is in lv_cb1....

regards

Pranav

pranav_nagpal2
Contributor
0 Kudos

Hi,

Check this code to get attributes

data lo_el_context type ref to if_wd_context_element.
    data ls_context type wd_this->element_context.
    data lv_cb1 like ls_context-cb2.
*   get element via lead selection
    lo_el_context = wd_context->get_element(  ).

*   get single attribute
    lo_el_context->get_attribute(
      exporting
        name =  `CB2`
      importing
        value = lv_cb1 ).

here cb2 is the attribute from which i am getting data....

and I am not able to find any error here in the procedure you have provided if you are not able to get data..... check all the mappings and see if you are not doing any thing like invalidating a node...

regards

Pranav

Former Member
0 Kudos

Hi Pranav

I want to make my child component reusable so i want to fetch mapped attribute and data dynamically.

the way suggested by you need attribute data fatching statically.

any context node can be mapped from parent to child and parent node will not be the same always.

pranav_nagpal2
Contributor
0 Kudos

Hi,

I am not sure why you want to make dynamic usage of attributes, this can be done even if you dont use dynamic programming....

Refer this DEMODYNAMIC component in SWDP_DEMO package for any details of dynamic context and attributes.....

regards

Pranav

Former Member
0 Kudos

Hi Consider the case of ALV in WD4A.

we map our context node to context node "DATA" of component salv_wd_table

so node DATA receives attributes and value from our context node and accordingly ALV is displayed.

similar kind of thing i am checking.

Thanks

Vishal Kapoor