Skip to Content
-1

Simple division operation in SAP sometimes works wrong?

Nov 18, 2016 at 04:22 PM

68

avatar image

Hi Everyone,

here you are a program, which divides 2 numbers:

---------------------------------
PROGRAM divide.

DATA: pack TYPE p DECIMALS 2,
n TYPE f VALUE '1000.5',
m TYPE f VALUE '10'.

pack = n / m.

WRITE pack.
---------------------------------

Result is 100.05 and this is wrong.
Correct result is 100.50


Where is a catch?

Our version is ECC 617

I do not believe that simple division sometimes does not really work in SAP.

Thanks,
Alex

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Sandra Rossi Nov 18, 2016 at 05:45 PM
2

sorry but 1000.5 / 10 gives 100.05, not 100.50 !

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Just to double check that Alexander didn't mean the other way around (that SAP is returning 100.50) I just ran his little program in SAP and it did return 100.05 as expected. Pheww - the world is still round!

2
Christopher Solomon
Nov 18, 2016 at 05:18 PM
0

Do you have "fixed point arithmatic" checked/selected for your program?

Share
10 |10000 characters needed characters left characters exceeded
Alexander Dolgorukov Nov 21, 2016 at 09:00 AM
0

False alarm, everything works as expected. Sorry!

Share
10 |10000 characters needed characters left characters exceeded