Posted: Wed Sep 05, 2007 7:11 pm Post subject: Currency Formatting in SAP Scripts
REQUIREMENT
We have to display amount i.e., WRBTR (4,500.00) from the table BSEG (Accounting Document Segment) in the format 450,000 where the document number (BELNR) and plant (BUKRS) are as specified in the selection screen. Invoice gets generated for the country Korea when we enter the document number and plant as 1600000000 and 3040. But unlike the reports, SAP SCRIPT by default displays the amount with two decimal places. This results in displaying incorrect amount for different countries. We cannot use the keyword 'CURRENCY' while coding inside the SAP Script. Then how can we achieve the currency formatting using SAP Scripts? This can be done by setting correct currency reference, using database structures that have amount field with currency references. This is explained in detail as follows.
SOLUTION
For an example, consider a structure called KOMK (Pricing Communication Header). It has two fields i.e., the currency reference field and the amount field.
1. WAERK - SD document currency (Description)
DATA TYPE: CUKY, LENGTH: 5.
2. FKWRT- Net value in document currency (Description)
DATA TYPE: CURR, LENGTH: 15.
In the report, we manipulate the amount to be displayed on the SAP Script i.e., WF_AMOUNT. It is written as shown below.
* Data Declaration.
DATA: WF_AMOUNT LIKE KOMK-FKWRT.
* Coding part (hard coded the value for simplicity)
SELECT SINGLE *FROM BSEG
WHERE BELNR = '1600000000' and
BUKRS = '3040' and
BUZID = '' and
KOART = 'S'.
WF_AMOUNT = BSEG-WRBTR.
KOMK-WAERK = 'KRW'.
(OR)
If BSEG structure has a field for currency reference, we can use the same structure for displaying amount in respective format.
* Data Declaration.
DATA: WF_AMOUNT LIKE BSEG-WRBTR.
* Coding part
WF_AMOUNT = BSEG-WRBTR.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.