 |
 |
| SAP Tips: |
|
 |
 |

ABAP/JAVA DEVELOPER TIPS
Fixed point arithmetic/SAPScript
Maulik Thakkar 03.28.2002
Rating: -4.07- (out of 5) Hall of fame tip of the month winner




|
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.
Code
REPORT YMHT10 .
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.
 |

|
|
 |
|
 |
 |
 |
 |
| TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of . |
|
| | |
All Rights Reserved, , TechTarget |
SearchSAP.com is a search service provided by TechTarget and is completely independent of and not affiliated with SAP AG.
|
|
|
|
|