cancel
Showing results for 
Search instead for 
Did you mean: 

How to copy data from one node to another?

former_member1191927
Participant
0 Kudos

Hi Gurus,

Can some one give me sample code to copy data from one context node to another in Webdynpro ABAP?? I need this very urgnetly?

Thanks,

Hari

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Not really all that difficult. I have a working sample, so you will have to adjust for your context structure/names. You would start by reading all the data from the source context:

data lo_nd_contacts type ref to if_wd_context_node.
  data lo_el_contacts type ref to if_wd_context_element.
  data ls_contacts type wd_this->element_contacts.
* navigate from <MEETING> to <CONTACTS> via lead selection
  lo_nd_contacts = lo_nd_meeting->get_child_node( name = wd_this->wdctx_contacts ).
* @TODO handle not set lead selection
  if lo_nd_contacts is initial.
  else.
    data l_contacts type standard table of zpm_cust_mt_ct.
    lo_nd_contacts->get_static_attributes_table( importing table = l_contacts ).
  endif.

So now you have all the data from the source context back into a normal ABAP internal table - l_contacts.

Do the context nodes have the same structure? If so you could just bind this internal table directly into the second context node (destination). Otherwise you probably want to build a new ABAP internal table and loop through the source copying the data selectively (MOVE-CORRESPONDING maybe) to the second internal table.

data lo_nd_pm_contacts2 type ref to if_wd_context_node.
*   navigate from <CONTEXT> to <PM_CONTACTS2> via lead selection
  lo_nd_pm_contacts2 = wd_context->get_child_node( name = wd_this->wdctx_pm_contacts2 ).
  lo_nd_pm_contacts2->bind_table( l_contacts ).

former_member1191927
Participant
0 Kudos

Thanks Thomas. That was really helpful.

Answers (0)