Skip to Content
avatar image
Former Member

Getting maximum value from node

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Apr 11, 2009 at 06:14 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 11, 2009 at 07:58 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 11, 2009 at 09:10 AM

    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

    Add comment
    10|10000 characters needed characters exceeded