cancel
Showing results for 
Search instead for 
Did you mean: 

Getting maximum value from node

Former Member
0 Kudos

hi,

I have one value node...i need to get maximum value from the lements added in it..

For e.g. suppose my value node name is Material and it has two attribute lineitem and material.

so now

Material

lineitem name

001 Winding

003 Screw.

005. Machine.

004 Transformer

002 Coil

Currently..i have run loop on this node and fetched maximum value by comparing each element (i.e 005)... can directly fetched value 005 without running loop..

Regards,

Jigar Oza

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Expert

if you want to make it shorting ascending order of node value.then you can compare the node value using

wdContext.nodeMaterial ().sortElement(){

new comparator(){

public int compare(Object x,Object y){

Integer a=new Integer((IWDNodeElement)x).getAttributeValue("lineitem").toString());

Integer b=new Integer((IWDNodeElement)y).getAttributeValue("lineitem").toString());

if(a==null){

return b=null?1:0;

}

return a.compareTo(b);

}

}

}

try to this above code it will sort ascending order of node...

thanks

jati

Former Member
0 Kudos

The loop should be no performance problem. Another possibility is to store the node element with the maximum value in a separate context attribute and update this attribute whenever an element is added or removed from the node. But I doubt it is worth this effort.

Armin

former_member214651
Active Contributor
0 Kudos

Hi Jigar,

For getting the highest value from the Node u can sort the Node in which u maintain the values (if the values are not coming from the Backend). If the values are copied from a RFC structure, then u can instruct the RFC developer to sort the table in the highest order of the key such that the maximum value is always in the first row before sending it to you. By this u can set the lead selection property of the value node to the first element of the Node.

In this way u can always get the highest value of the table without looping.

Regards,

Poojith M V