cancel
Showing results for 
Search instead for 
Did you mean: 

Strange behavior of Multiply function

Former Member
0 Kudos

Dear friends,

I am using the standard multiply function and gives the wrong output if input value is more than 6 digits. I am simply multiplying by 100.

Any alternate solution for this? I have also tried with UDF, but no success.

I will appreciate if any one can explain why this function behaves like this.

Regards,

Sarvesh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

maybe this helps:

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

Regards

Patrick

Former Member
0 Kudos

Thanks for your reply.

Well, already gone through this blog.

Former Member
0 Kudos

Hi,

Message Mapping uses float values which are not very precise.

It's even described in SAP Help:

> Also note that Java values of type float are converted to the second system before the calculation. The result is calculated there and then this result is converted back to decimal format. The conversion may result in positions after the decimal point that are periodically repeated and then automatically cut off. In the decimal system, this can result in inaccurate results (example: 2.11 + 22.11 = 24.220001). If the number of positions after the decimal point is to be restricted to two, for example, in the case of values for a currency, you can format the values after the calculation by using the standard function FormatNum.

If you use double values in User-Defined-Functions it's not much better.

So guess the best is tou use java.math package claesses BigDecimal and BigInteger like described in the mentioned blog.

Hope it helps!

Regards

Patrick

henrique_pinto
Active Contributor
0 Kudos

As described in the blog linked in the blog above, there's a standard solution for this.

/people/thorsten.nordholmsbirk/blog/2006/08/25/new-arithmetic-and-statistical-functions-in-message-mappings-in-sp18

https://service.sap.com/sap/support/notes/958486

Regards,

Henrique.

Former Member
0 Kudos

Thanks for yor help.

Finally I soved my problem by using an UDF.

Answers (0)