Skip to Content
author's profile photo Former Member
Former Member

Strange error in SUM function in XI

Hi geeks,

We are encountering a strange issue in SUM functionality in XI.

The Scenario is :

We have a pipe delimited source file and INVOIC01 idoc as target. each line in the source file will create a segment E1EDP01 in the target IDOC.

All the values given in the file should be summed and mapped to E1EDS01 segment in the idoc.

In one such strange case the sum of the values generated by the SUM function in XI is 2 cents lesser what we manually calculate using Calculator or Excel . There are about 100+ items in the file. This not the case always it happens once in a while.

Have any of you faced such strange errors. If yes please throw some light on the solution for this issue.

Thanks,

Noorul

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Posted on Nov 29, 2007 at 12:32 AM

    HI Noorul,

    Did you check if the Sum function is doing some kind of a rounding?

    Regards,

    Ravi Kanth Talagana

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2007 at 12:55 AM

    Noorul,

    I would agree with ravikanth....see if its rounding the decimal digits and what is being used..you might want to add a udf to do proper java sum ...according to your specifications..so that it doesent round it up...ie dont cast the final sum to an int..leave it as a double or float.

    Regards

    Ravi Raman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2007 at 01:00 AM

    Hi Noorul,

    See whether OSS note 958486 is applicable.

    - Pinkle

    Message was edited by:

    Pinkle Naik

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Noorul,

      I looked at the note..if your basis is good get them to look at it ..and apply sp 18.if you are on PI..then that might not apply, however its a java summation issue..and the rounding involved herewith ..you can bypass using the XI sum function with a custom function...be sure to test it before you use it...:-))

      Regards

      Ravi Raman

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2007 at 07:08 AM

    Hi

    Check this out

    /people/thorsten.nordholmsbirk/blog/2006/04/03/never-ever-use-xis-built-in-arithmetic-functions

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2007 at 04:40 PM

    Hey guys,

    Thanks for your responses. Now I found it is a standard bug in XI which has been corrected in SP 18. But we have only SP16.

    I need to write java code to sum at the context level.

    Can you guys throw some light on that.

    Best Regards

    Noorul

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 29, 2007 at 10:03 PM

    Hi folks,

    Thanks for your help. I solved this by writing my own code

    double sum = 0;

    String value;

    for (int i= 0; i< a.length; i++)

    {

    sum = sum + Double.parseDouble(a<i>);

    }

    value = Double.toString(sum);

    BigDecimal bg1 = new BigDecimal(value);

    BigDecimal bg2 = bg1.setScale(2, BigDecimal.ROUND_HALF_DOWN);

    result.addValue(bg2.toString());

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.