on 03-30-2007 9:47 AM
Hi SDN,
I need copy value node to model node. How create the instace of model node, for copy this value node.
This model node is an import table of R3.
Thank's
Copyingd data from value node to model node is not possible because model node holds reference whose information is not there in value node.
What u can do
1>u can iterate over value node.
2>Get the reference of parent model node.
3>Add objects of child model node to the parent model node.
4>Copy values using copy corresponding method.
<Parent Model Node's class> input =
wdContext.current<Parent Model Node>element().modelObject();
int size=wdContext.node<value node>().size();
for(int i=0;i<size;i++)
{
IWDNode el=wdContext.node<value node>().getElementAt(i);
input.add<ChildNode>(new <ChildNodeModelClass>());
wdContext.node<ChildNode>.moveLast();
wdCopyservice.copyCorresponding(el,wdContext.current<ChildModelNode>);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If you want to copy value node to model node then loop through the value node and set the corresponding values to model node.
use the following code:
IPublic/Private<Comp/view>.I<ModelNode>Element e1;
for (int i = 0; i < wdContext.node< ValueNode>.size(); i++) {
// Create the model/structure instance
Zsd_Pmt_S_Prodgrd elem = new Zsd_Pmt_S_Prodgrd(); (for example)
// set the values
elem.set<attribute1>(wdContext.node<ValueNode>()
.get<ValueNode>ElementAt(i).get<Element>());
elem.set<attribute2> (wdContext.node<ValueNode>()
.get<ValueNode>ElementAt(i).get<Element>());
e1 = wdContext.node<ModelNode>().create<ModelNode>Element(elem);
wdContext.node<ModelNode>().addElement(e1);
}
Regards,
Jhansi
The method WDCopyService.copyElements copies only those attributes from "source" which are present in "target" and if they match (the names equal case-sensitive and the types are compatible).Please check if your contexts nodes have the same sets of attributes. And <b>WDCopyService cannot copy the value node to model node</b>.It is used when you want to copy model node to value node.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
if it's not created you should first bind the model node before filling:
wdContext.nodeModelNode().bind(new Model);
after that, you can iterate over that value table.
You can also try to use the wdCopyService. But I think especially for tables
it's more secure to iterate over the table.
Sometimes the copied values are not passed to the R3 System.
regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The node value have same structure of model node.
But when i copy value node to model node A, this not created.
The instance is not careated, and return error.
.value node
.Model node
-> A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If the Elements doesn't have the same type you can just doing a loop over your table:
wdContext.nodeModelTable().invalidate();
for(int i = 0;i < wdContext.nodeValueNode().size();i++){
IPublicComponent.IModelTableElement element = wdContext.createModelTableElement(new ModelTableType);
wdContext.nodeModelTable().addElement(element);
element.setAttribute1(wdContext.nodeValueNode().getElementAt(i).getAttributeValue("Attribute1").toString());
element.setAttribure2(wdContext.nodeValueNode().getElementAt(i).getAttributeValue("Attribute1").toString());
..................
}
Best regards,
Dennis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if both the node have same structure you can use,
WDCopyService.copySubtree((IWDNode)ModelNode,(IWDNode)ValueNode);
for them having different structure , you gotta code like, in iterative manner
java.util.List lst = wdContext.current<ModelNode>Element().modelObject().get<Model>Response_Sync().get<ListOfElements>();
java.util.List newList = new java.util.ArrayList();
IPublic<Component>.I<ValueNode>Element sData = null;
for (int i =0; i < lst.size(); i++){
sData = wdContext.create<ValueNode>Element();
<complete path>.<ModelNode> so = (<complete path like com.sap...>.<ModelNode>)lst.get(i);
sData.setAttributeOne(so.getAttributeOne());
sData.setAttributeTwo(so.getAttributeTwo());
sData.setAttributeThree(so.getAttributeThree());
newList.add(sData);
}
wdContext.node<name>().bind(newList);
hope it helps
regards
Message was edited by:
abhijeet mukkawar
Message was edited by:
abhijeet mukkawar
Message was edited by:
abhijeet mukkawar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
you can create the instance of the model node. The variou classes are shown under Models -> <ur model Name> -> Model Classes There you can find the modle nodes that you can instantiated.
you can copy ur value node to model node as:
<ModelNode> model = new <ModelNode>();
wdContext.node<ModelNode>().bind(model);
model.set<attributenname>(valueElement.get<attributename>);
<b>Do rewards point if it helps.</b>
Abhinav Sharma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.