cancel
Showing results for 
Search instead for 
Did you mean: 

copy values from Context Value Node to Model Node - nodes are incompatible

Former Member
0 Kudos

Hello Everyone,

I have to copy values from Context Value Node to Model Node (i.e. V_Node to M_Node) . I am using the following code:

WDCopyService.copyElements(wdContext.nodeV_Node(), wdContext.nodeM_Node());

it is giving me runtime error:

com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: nodes are incompatible

But I have no problem to use this WDCopyService.copyElements to copy values from Model Node to Value Node as below:

WDCopyService.copyElements(wdContext.nodeM_Node(), wdContext.nodeV_Node());

Could anyone please tell me why and how to resolve the iseue.

Thanks alot, Jin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Please have a look at this thread,

Regards

Saravanan K

Former Member
0 Kudos

Thanks Saravanan and Manoj both very much for your quick reply and all the links.

Can anyone advise me a simple solution with sample code?

Thanks again, Jin

Former Member
0 Kudos

Hi,

Please traverse the contents of the value node and pass the values to the model node.

Please have a look at this thread,

Regards

Saravanan K

former_member214651
Active Contributor
0 Kudos

Hi Jin,

To use copy service API, u need to satisfy 2 condition for the attributes of source node and target node:

1. The name of the attribute should be same (including the case of the name)- Abc is different from ABC

2. Type of the attribute should also be the same.

copy elements works for copying values from Model node to context and does not work vice-versa. To enable the copying of context node to model node, use copycorresponding API.

Eg:

int contextNodeSize = wdContext().node<contextNodeName>().size();
for(int i = 0; i < contextNodeSize; i++)
{
     <modelNodeName> modelObject = new <modelNodeName>();
     <contextNodeName>Element contextObject = wdContext().node<contextNodeName>().get<contextNodeName>ElementAt(i);
     WDCopyService.copyCorresponding(contextObject, modelObject);
}

This will copy the values from Context Node to Model Node.

Hope this helps you.

Regards,

Poojith MV

Former Member
0 Kudos

Hi Poojith,

Thank you so much for proviing such easy clear solution to resolve my issue.

Thanks Saravanan again for the link.

I'm closing this thread and will open new one for another issue.

Thanks all again, Jin

Answers (3)

Answers (3)

Former Member
0 Kudos

Dear Jin,

By using the Copy Service, you can not copy the data from Value Node to Model Node.

Cheers!!!

Umang

Former Member
0 Kudos

Hi,

I afraid, WDCopyService contains some limitations in copying value / Model nodes.

Please have a look at this thread,

If not worked, you can traverse the value node and pass the value to Model node

Regards

Saravanan K

Former Member
0 Kudos

Hi,

Just go through the Java doc for its API, it will answer your question.

Here is the [Link|http://help.sap.com/javadocs/NW04S/SPS09/wd/com/sap/tc/webdynpro/progmodel/api/WDCopyService.html#copyElements(com.sap.tc.webdynpro.progmodel.api.IWDNode, com.sap.tc.webdynpro.progmodel.api.IWDNode)]

Hope it helps.

Regards,

Manoj