cancel
Showing results for 
Search instead for 
Did you mean: 

Pass value between model context

Former Member
0 Kudos

Hi,

i want to pass output of the one model contex attribute to another model context attribute input.

>Test1ModelNodeInput

> OutputNode1

> Node1

--Attr1(output model attribute)

>Test2ModelNodeInput

>OutputNode2

--Attr2(input model attribute)

Regards

Anumit

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

try WDCopyService.copyCorresponding over a "for" loop

WDCopyService.copyCorresponding(wdContext.node1().current1Element(),

wdContext.2().nodeInput_Zcmdbsystem().current2Element());

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi u can use Copy service


WDCopyService.copyElements(wdContext.nodeSourceNode(),wdContext.nodeTargetNode());

But make sure that ur both nodes are identical in structure.

for this you should also use the following import statment in the Beginning.

import com.sap.tc.webdynpro.progmodel.api.WDCopyService

Rewards points if helpful

regards

Surender Dahiya

former_member751941
Active Contributor
0 Kudos

Hi Anumit,

To copy data from master node to target node

try

{

IPrivateDialogView.ITargetNode TargetNode = wdContext.nodeTarget();

IPrivateDialogView. IMasterNode masterNode = wdContext.nodeMaster();

int size = masterNode.size();

for (int i = 0; i < size; i++)

{

IPrivateDialogView. IMasterElement masterElement = (IPrivateDialogView. IMasterElement)wdContext.nodeMaster ().getElementAt(i);

IPrivateDialogView.ITargetNode node = wdContext.nodeTarget();

IPrivateDialogView.ITargetElement element = node.createTargetElement();

WDCopyService.copyCorresponding(masterElement, element);

node.addElement(element);

}

}

catch(Exception e)

{

e.printStackTrace();

}

or you can use this code also

try{

WDCopyService.copyElements(wdContext.nodeMaster(),wdContext.nodeTarget());

}

catch(Exception e)

{

e.printStackTrace();

}

Regards,

Mithu

Former Member
0 Kudos

hi,

for this get value from output node by get method and set this value in input field of another attribute by set method.

wdContext.currentContextElement().setAttribute1(wdContext.currentContextElement().getAttribute2());

Regards

Trilochan