on 11-29-2007 12:00 AM
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
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());
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Check this out
/people/thorsten.nordholmsbirk/blog/2006/04/03/never-ever-use-xis-built-in-arithmetic-functions
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Noorul,
See whether OSS note 958486 is applicable.
- Pinkle
Message was edited by:
Pinkle Naik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Noorul,
Did you check if the Sum function is doing some kind of a rounding?
Regards,
Ravi Kanth Talagana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.