cancel
Showing results for 
Search instead for 
Did you mean: 

SUM Function not working as Expected

Former Member
0 Kudos

Hello All,

I am using the SUM function in my mapping and summation happens as expected for normal small amounts.

If i provide big digits and cents,Some times i dont know why it is giving wrong sum, difference in cents

Is there any thing to do with that?

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
 Is there any thing to do with that?

If you are in XI3.0 then yes there is an issue that Arithmetic and Statistical Functions does not work properly.

Basically you need to create below string in your exchangeProfile.

com.sap.aii.mappingtool.flib3.bigdecimalarithmetic = true

for more information have a look into this blog.. /people/thorsten.nordholmsbirk/blog/2006/08/25/new-arithmetic-and-statistical-functions-in-message-mappings-in-sp18

I had faced the same problem and solved it by configuring the above string.

Note: You have to re-start the JAVA Server after doing above configuration.

Other temporary solution is to use UDF with BigDecimal method.

Former Member
0 Kudos

Sarvesh,

But we are using PI 7.0 with SP 14.

What can i do in this case?

Regards

Former Member
0 Kudos

I am not sure about PI7.0 But may be you can try this in you Dev system to check if it works otherwise create UDF with BigDecimal method to solve your issue.

Former Member
0 Kudos

Ok Sarvesh, I will try and let you know

Regards

Vamsi

Former Member
0 Kudos

Sarvesh / Rahul,

Even though i activated the parameter in exchange profile & restarted the Server, getting the same issue

Could you please let me know the UDF for this to solve my issue

Regards

Former Member
0 Kudos

I am using the following UDF, but it is giving the final SUM value like before with 0.1 cents difference

java.math.BigDecimal;

double newA = Float.parseFloat(a);

BigDecimal bigSum = new BigDecimal(newA);

return bigSum.toString();

Please let me know

Regards

Former Member
0 Kudos

Try this one..

Imports: java.math.BigDecimal;

BigDecimal sum = new BigDecimal (  0.0D  ) ; 
for(int i = 0; i <a.length; i++)
{
     BigDecimal big1 = new BigDecimal (a<i>) ; 
     sum = big1.add( sum ) ; // sum = sum + big1; 
}
result.addValue ( sum +"" );

Mapping Step:

Source ->RemoveContext->UDF--->Target

Former Member
0 Kudos

Thanks So much Sarvesh. Solved the Issue

Regards

Vamsi

Answers (2)

Answers (2)

Former Member
0 Kudos

Its the java math error . Convert the numbers to BigDecimal . Also scale up or down the decimal if you want .

Former Member
0 Kudos

Write an UDF in which you need to use java.math.BigDecimal class.

Please reference the following thread:

Regards

Liang