cancel
Showing results for 
Search instead for 
Did you mean: 

Code to transfer data from one context to other

bhakti2
Active Participant
0 Kudos

hi,

Kindly provide simple code of transfering data from one context node1(0...n) to other context node2 (0...n)

node1 has data at the start of the view and node2 is empty so it needs to be populate with same data as node1 in wdinit method of the view

thanks in advance

b

Accepted Solutions (0)

Answers (2)

Answers (2)

bhakti2
Active Participant
0 Kudos

thrz no help for WDJ like there is google for java. had to myself hunt out the sample code. however, thank u for the answers

Qualiture
Active Contributor
0 Kudos

Hi,

Is it so hard to figure this out yourself? Anyway, it cannot be simpler than this:

WDCopyService.copyElements(node1, node2);

See also API http://help.sap.com/javadocs/NW04S/SPS09/wd/com/sap/tc/webdynpro/progmodel/api/WDCopyService.html

Best regards,

Robin

bhakti2
Active Participant
0 Kudos

hi,

thanks for the response

sorry for asking basic question

the structure of two nodes is not same so I need to write a for loop

kindly help me with the reference coding

thank you

b

Qualiture
Active Contributor
0 Kudos

If both node's structures are not equal, you need to code the following:

  • Iterate through the elements of node1

  • within the loop, create and add a new element for node2

  • set the node2 attributes with the appropriate node1 values

Have a look at the IWDNode and IWDNodeElement API's for more info on the iterateElements(), createAndAdd<yourNode>Element() and get/set attributevalue methods.

Robin