cancel
Showing results for 
Search instead for 
Did you mean: 

wdCopyService Error: Node has no valid parent?

Former Member
0 Kudos

I tried to do this:

WDCopyService.copyElements(wdContext.nodeResponse25(), wdContext.nodeHeader2());

However it gives the error:

"Node(DemoWSViewSearchOrder.Order.Header2): cannot bind or add elements because the node has no valid parent"

So I initiate the node with this:

IPrivateDemoWSViewSearchOrder.IHeader2Element ele2 =

wdContext.nodeHeader2().createHeader2Element();

wdContext.nodeHeader2().addElement(ele2);

However it is still giving the error:

"Node(DemoWSViewSearchOrder.Order.Header2): cannot bind or add elements because the node has no valid parent"

Any idea why?

Accepted Solutions (1)

Accepted Solutions (1)

former_member185086
Active Contributor
0 Kudos

Hi

As you said :I initiate the node with this?

To get facility of WDCopyService no need to initiate any node belongs to model .Only care need to take is

Use this method after execution of the model after executing and invalidating the response node of model,

updated data is there. now u can either bind it to any table or copy it to another node using WDCopyService.

Regarding this error

Node(DemoWSViewSearchOrder.Order.Header2): cannot bind or add elements because the node has no valid parent

It need a identification of Source (which contain the updated data after executing the model), and target (where u want copy of this data)

read this carefully

@throws RuntimeException if target is a model node and 
   *    source is not a model node holding the same class.

Best Regards

Satish Kumar

Former Member
0 Kudos

Hi there,

You are right satish, I do not need to initiate anything for VALUE node.. I made a mistake somewhere..

Thanks!

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi there..

I have successfully COPIEd from Model Node (output) to Value node.

Now I am trying to copy them into the input node of another model with same structure.. Any advise on that? When I tried to use wdCopyService, it say nodes are incompatible..

Does that means I must do 1 attribute b y 1 attribute when copying over?

former_member185086
Active Contributor
0 Kudos

Hi

Sorry to mentioned it before that : for use of WDCopyService signature of the nodes should be same.

Again u are doing mistake here that providing a input to a model node and u are using CopyService ,

Please understand the context of uses of this standard method ,not at all related to give input to model node.

Simplest is get the value form and set it to model node.(too many thing r there before executing the model that validation ,null pointer check. How u will achieve this by using copyService and it may u r not doing these kind of operation in your implementation ,Even then avoid this kind of uses there)

Best Regards

Satish Kumar

former_member197348
Active Contributor
0 Kudos

Hi Jackson,

Did you initialize the node Order?

and I guess you must have initialized the node DemoWSViewSearchOrder.

In fact, you need to initialize entire tree of the node Order up to top level node.

If you have done the same, please let me know the error stack, node structure and what you are trying to do.

Regards,

Siva

Former Member
0 Kudos

Hi there,

I tried to Model Node initiate with this:

Sa_Display_Header tmp = new Sa_Display_Header(model);

IPrivateDemoWSViewSearchOrder.ISa_Display_HeaderElement ele =

wdContext.nodeSa_Display_Header().createSa_Display_HeaderElement(tmp);

wdContext.nodeSa_Display_Header().addElement(ele);

But it says:

com.sap.tc.webdynpro.progmodel.context.ContextException: Node(DemoWSViewSearchOrder.Request_Sa_Display_Header.Sa_Display_Header): must not add elements to a Node of cardinality 0..1 or 1..1

How can I initiate a 0..1 or 1..1 model node?

Former Member
0 Kudos

Hi,

Please do as following:


if(0 >= wdContext.nodeXYZ().size()) {
    IPrivate<Your View>.IXYZElement xyzEle = wdContext.nodeXYZ().createXYZElement();
    wdContext.nodeXYZ().addElement(xyzEle);
}

Here XYZ is the node with cardinality 0..1 or 1..1.

Hope it helps.

Cheers,

Manoj

former_member201361
Active Contributor
0 Kudos

Hi Jackson,

WDCopyService.copyElements(wdContext.nodeResponse25(), wdContext.nodeHeader2());

here nodeResponse25() is the model node and Header2 is the value node, right ?.

wdCopyservices will not work for this, instead give the valid model node which is the sub node of response node. for eg :

if ur node structure is :

Response - model node

responseMsg - model node

Output - model node

Name - model attribute.

and ur value node structure is :

Header - value node

Name - value attribute

then use WDCopyService.copyElements(wdContext.nodeOutput, wdContext.nodeHeader());

Note : for using the WDCopyservices , the two nodes should have same Structure (attributes with same type and ensure that even cardinality matches).

Thanks and Regards

Former Member
0 Kudos

Thank you. Yes I am already using the immediate node above the element.

if ur VALUE node structure is :

Response - model node

responseMsg - model node

Output - model node

Name - model attribute.

I have to initiate all the respective node is that the case? I can't just initiate the top most node or the node that I am using?