Problem solve Get help with specific problems with your technologies, process and projects.

Fixed point arithmetic/SAPScript

In 4.6c when you create SAPScript programs, SAP does not set the "Fixed Point Arithmetic" Flag automatically.

This tip is almost too trivial. We learn it as basics but tend to forget it sometimes and stop short of claiming...

it as a bug in SAP. In 4.6c when you create SAPScript programs, SAP does not set the "Fixed Point Arithmetic" Flag automatically. You have to go to the attributes and change set it manually. If you leave it blank, the ABAP interpreter will ignore the decimals in floating point calculations and you may potentially have incorrect values printing on the forms. In the example below you will have V_Unit_Price = 0.07 if the flag is not set 66.35 if the flag is set, which is correct. This is what the SAP documentation for Field TRDIR-FIXPT says. If you mark this checkbox, all caluculations 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.


DATA:  v_kwmeng(8)        Type P Decimals 2,
       v_kzwi2            Like Komp-Kzwi2,
       v_unit_price       Like Vbdpa-Netpr.

V_Kwmeng = '400.000'.
V_Kzwi2  = '26540.00'.

v_unit_price = v_kzwi2 / v_kwmeng.

write: /01 v_unit_price.
This was last published in March 2002

Dig Deeper on SAPscript and Smart Forms



Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.