cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing through value node

Former Member
0 Kudos

HI,

I have a value node and model node in my current view. say view1. the model node is mapped to custom controller model node which executes bapi initialy to retrieve data from r/3. now i want to assign values in my valued node to retrieve data. and i want to check the size of the model node. my value node has recursive node and some value attributes which is mapped to table. i want to set the value node value attirbutes as the values of model node which is available in current view itslef.

I used following code it displays only description not the exact value.

newDElement = node.createDElement();

node.addElement(newDElement);

newDElementnt.setValone(wdContext.currentBapiDesc().getDescription());

suggest me for the solution.

regards,

Ganesh.D

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member185029
Active Contributor
0 Kudos

hi,

Please reframe your question and elaborate it more.

Ashutosh

Former Member
0 Kudos

Hi,

I have value node and model node in current view. model node is mapped to custom controller which retrieves r/3 data. i want assign current iview model node attribute to value node's attribute.

ex. valuenode1.id = modelnode1.id

id is attribute of valuenode1 and modelnode1.

modelnode1 is mapped to custom controller modelnoted2.

regards,

Ganesh.D

Former Member
0 Kudos

Hi Ganesh,

If the names of the attributes of the value node and the model node is exactly same, then you can use WDCopyService class's copyCorresponding method. This will copy the values from and to similarly named context attributes.

Go through the documentation

<a href="https://media.sdn.sap.com/javadocs/NW04/SPS15/wd/com/sap/tc/webdynpro/progmodel/api/WDCopyService.html">here</a>.

Regards,

Satyajit.

Former Member
0 Kudos

Hi Satyajit,

Can you explain in coding(example) or any other way other than wdcopyservice.

regards,

Ganesh.D

lajitha_menon
Contributor
0 Kudos

Hi Ganesh,

Use the foll code to copy from a model node to a value node. It will copy all fields, whose names are similar. You can put this as a generic method, taking ModelNode and ValueNode as input parameters. They are of type com.sap.tc.webdynpro.progmodel.api.IWDNode

IWDNodeElement elemSrc;

IWDNodeElement elemDest;

int size = ModelNode.size();

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

ModelNode.setLeadSelection(i);

elemSrc = ModelNode.getCurrentElement();

elemDest = ValueNode.createElement();

ValueNode.addElement(elemDest);

WDCopyService.copyCorresponding(elemSrc, elemDest);

}

Regards,

LM

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi LM

Just to simplify your code a bit

IWDNodeElement elemSrc;
IWDNodeElement elemDest;
int size = ModelNode.size();
for (int i = 0; i < size; i++) {

 <b>elemSrc = ModelNode.getElementAt(i);</b>
 elemDest = ValueNode.createElement();
 ValueNode.addElement(elemDest);
 WDCopyService.copyCorresponding(elemSrc, elemDest);
}

BR

Sergei

Former Member
0 Kudos

Hi,

Its is working fine with my questions code. Actualy the input for the model is which i gave is wrong. when i changed it is working.Thanks.

regards,

Ganesh.D