Home > SAP Tips > ABAP/Java developer tips > Fixed point arithmetic/SAPScript
SAP Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

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


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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.

Rate this Tip
To rate tips, you must be a member of SearchSAP.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
ABAP/Java developer tips
Select Text fields: Case-insensitive
Finding BADIs you can use
Is this the quickest way to find a BADI?
ABAP Objects in SAP Workflow to provide improved performance
Easily debug error messages in SAP processes
Accessing private attributes in ABAP Objects
Find a BADI in a minute
Top 10 SAP tips of 2007
How to transport an SAP query in R/3 4.6x
How to switch off message determination in BAPI_PO_CREATE1

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

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.

HomeNewsTopicsBlogsTipsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
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 technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2000 - 2008, TechTarget | Read our Privacy Policy
SearchSAP.com is a search service provided by TechTarget and is completely
independent of and not affiliated with SAP AG.
  TechTarget - The IT Media ROI Experts