cancel
Showing results for 
Search instead for 
Did you mean: 

Strange error in SUM function in XI

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

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());

Former Member
0 Kudos

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

Former Member
0 Kudos

THe help to create a UDF is available in the 3446 mentioned above.

Former Member
0 Kudos

Hi

Check this out

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

Thanks

Former Member
0 Kudos

Hi Noorul,

See whether OSS note 958486 is applicable.

- Pinkle

Message was edited by:

Pinkle Naik

ravi_raman2
Active Contributor
0 Kudos

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

ravi_raman2
Active Contributor
0 Kudos

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

former_member181962
Active Contributor
0 Kudos

HI Noorul,

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

Regards,

Ravi Kanth Talagana