on 04-04-2006 11:31 AM
Hi, I suspect the default SUM function in XI IB to calculate wrong on big decimal values. I tried the user defined function described at the bottom of this thread: ?
But I miss out something. It does not SUM for the whole document, as the default SUM function would do.
Any ideas?
Would any service packs correct this? Anyone else with this problem? Is it a bug?
Hi Rune,
Are you trying to calculate the sum of the a particular field in the whole of the document ?
the maybe you can try this code :
for (int i = 0; i<a.length; i++)
{
temp = Integer.parseInt(a<i>);
tempSum = tempSum + temp ;
}
As Mike suggested you have to handle the context.Make the context of the field to be summed to the immediate parent or the root.
Pass the field as input and return the value of tempSum to get the total sum.
Message was edited by: Shabarish Vijayakumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I need to calculate for the particular field of the whole document. I struggle with a Java calulation bug that seems to be in the SUM mapping function.
This code should handle large numbers and get rid of the error:
BigDecimal d1 = new BigDecimal(a); // original number
BigDecimal d2 = d1.setScale(2, BigDecimal.ROUND_HALF_DOWN); // "normal" rnd rule
String result = d2.toString();
return result;
But I this return a value of that field, not a SUM of all fileds in the whole document (as SUM would do).
<i>I think I have to use a loop as described, but what should be in parameter b (or a)?</i>
Message was edited by: Rune Johansen
Message was edited by: Rune Johansen
Hi Rune ,
Set the context of the field to the root node on which you are trying to calculate the sum and write a user defined function and use the code as mentioned by Shabarish . You can also use <i>Double.parseDouble(b)</i> instead of the Integer wrapper Class if it truncates your decimal value.
Thanks & Regards,
Ashish Sharma .
Hi,
what do you mean " It does not SUM for the whole document" ?
did you set the correct context ? if you want to sum
numbers from different nodes ?
Regards,
michal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.