Fixed point arithmetic/SAPScript

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 =

    Requires Free Membership to View

v_kzwi2 / v_kwmeng. write: /01 v_unit_price.

This was first published in March 2002

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
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
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.