Intelligence Information Technology Communication : raviramanujam@gmail.com

Friday, May 6, 2011

Rounding off Amount fields


In SAP it is a bit tricky, s SAP stores amount fields as currency types. These fields are stored internally with 2 decimals, irrespective of the currency used. It can be easily done using write statement if you want to round the amount field in the report. If you want to round up and store as a currency amount field itself. This is a problem in SAP query reports. The user wanted amount fields to appear rounded to nearest integer. SAP has some built-in-functions like ceil, floor but they can not be used as it is, due to the fact that the amount is stored internally with 2 decimals. Most of the currencies are with 2 decimals . This can be easily achieved by the following operation. A constant need to be defined with value 0.5 rounding is achieved by amount = floor( amount + constant ). There are currencies with other than 2 decimals. For example, Bahrain Dinar, Omani Riyal, Japanese Yen. The concept is same, but with an additional conversion. There is a BAPI function module to convert currency fields to external and vice the versa. Using these FMs convert the amount to first external format. Apply the formula as mentioned above and again using the BAPI FM convert it back to internal format.

No comments:

Indian Temples History.