cancel
Showing results for 
Search instead for 
Did you mean: 

Can't we multiply decimal numbers in SAP ABAP?

yalcin_mete
Participant
0 Kudos

Hi Masters,
Programming languages ​​are primarily expected to perform mathematical operations correctly.
I tried a lot of data types, but I couldn't multiply two decimal numbers into the abap program properly.

Can you help me ?

 

yalcin_mete_0-1715283033553.png

thanks

 

 

Sandra_Rossi
Active Contributor
0 Kudos
It has been discussed a lot -> search program attribute fixed-decimal point site:sap.com ... The number you see in debug doesn't mean the actual number, the number of decimals is adjusted in the display depending on the currency code.
View Entire Topic
Dmytro_K
Explorer

Hi,

you can multiply two decimal numbers in your ABAP program properly if the "Fixed point arithmetic" checkbox is marked in the program attributes (see Case 1 below, on the left side).

Figure_1.jpg

If the mentioned field isn't checked I get the same result as in your program (see Case 2 on the right side).

In my system in your Function Group V61A the "Fixed point arithmetic" checkbox is not marked:

Figure_2.jpg

In the help (F1) for this field:

If you mark this checkbox, all calculations in the program will use fixed point arithmetic.

If you do not, packed numbers (ABAP/4 type P, Dictionary types CURR, DEC or QUAN) will be treated as integers when they are used in assignments, comparisons, and calculations, irrespective of the number of decimal places defined. Intermediate results in arithmetic calculations will also be rounded to the next whole number. The number of decimal places defined is only taken into account when you output the answer using the WRITE statement.

By the way, the program status for the Function Group is "T" (Test Program). Maybe you should use for your purposes another, production, program, with fixed point arithmetic?

Best regards.

 

yalcin_mete
Participant
0 Kudos

Thank you very much to everyone for your explanations and comments. But this "function group" being studied is currently used by all users in the live system. Therefore I cannot change the "fixed point arithmetic" property anymore. One point I don't understand is this: Why work with the "fixed point arithmetic" feature removed? If working with decimal numbers, wouldn't anyone want to see the correct mathematical operations? If you do not want to work with decimal numbers, you can work with integers in the program. Why would you remove the "fixed point arithmetic" feature? It doesn't make sense to me.

yalcin_mete_0-1715602579496.png

Thanks .

 

Sandra_Rossi
Active Contributor
0 Kudos
@yalcin_mete It's a very old flag but you must deal with it. If you now understand how it works, you should be able to either solve or maybe the calculation is correct.