cancel
Showing results for 
Search instead for 
Did you mean: 

WDCopyService.copySubtree - WDRuntimeException: nodes are incompatible

0 Kudos

Hi,

I'm trying to use the WDCopyService zu copy a contextnode (0..n) to a modelnode (0..n).

WDCopyService.copySubtree( wdContext.nodeMyContext(), wdContext.nodeMyModel() )

All I get at runtime is this:

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

Both nodes are structure-binded to the structure of the imported model.

Cardinality, attributes and attribute-names are the same.

The contextnode is mapped to the interface-controller and there marked as input-parameter.

Copying this node within the context works. Copying to the model utterly fails.

Any ideas on this?

Thanks in advance.

Alf

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

WDCOpySubTree requires both the nodes to have the same depth and same structure insdie . Or both of them similar in that way.Or they recursive.

In case they are of a single level, try copyCorresponding and check.

And are they value node or model nodes. In case if they are model nodes are they from the sameclass..

Can u give us the complete structure of both the nodes.

Regards

Bharathwaj

Regards

Bharathwaj

Answers (2)

Answers (2)

Yashpal
Active Contributor
0 Kudos

Hi Alfred,

may i know why u want to copy data from value nodes to model nodes. actually model nodes are used to bind with the model i.e RFC .

Regards,

yashpal

Former Member
0 Kudos

Hi,

Oh ya ! I doubt if you use WDCopyService to copy data from value node to a nodel node.

You have to create an instance of the model class and use bind to set this values.

Regards

Bharathwaj

0 Kudos

> Hi Alfred,

> may i know why u want to copy data from

> y data from value nodes to model nodes. actually

> model nodes are used to bind with the model i.e RFC .

>

> Regards,

> yashpal

Hi Yasphal,

I need to modify some user-input to use as model-input values.

My approach was like this:

- view-context -binding-> comp-controller (context-node)

- modify comp-controller (context-node)

- WDCopyService ( context-node; model-node )

- execute model

Seems I have to write the modified input directly into a/the model node ...

Alf

Former Member
0 Kudos

Hi Alfred,

did u find a solution for this? I'm facing the same problem... could u provide a code snippet???

thank u in advance,

Stefano

Former Member
0 Kudos

There is no solution. You have to instance the model classes and assign the values to them directly. Then you create an element of the model node with the instanced model classs as input and add this element to the node.

Regards.

Francisco.

former_member182372
Active Contributor
0 Kudos

Hi Alf,

From CopyService implementation:

public void copyElements(IWDNode source, IWDNode target)
{
	Class sourceClass = ((NodeInfo)source.getNodeInfo()).getElementClass();
	Class targetClass = ((NodeInfo)target.getNodeInfo()).getElementClass();
	if(targetClass != null && (sourceClass == null || !targetClass.isAssignableFrom(sourceClass)))
		throw new WDRuntimeException("nodes are incompatible");
...
}

So, if your target is model, your source MUST be model node (to have assigned element class) AND assignable, which means <i>Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter. It returns true if so; otherwise it returns false. If this Class object represents a primitive type, this method returns true if the specified Class parameter is exactly this Class object; otherwise it returns false. </i>( from http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html ).

Best regards, Maksim Rashchynski.