WTF Solution

How To Convert Amount In Words In SAP ABAP 2025

Convert amount in words, This means the user enters an amount in currency, which is converted into words. For example, in India, if the user enters 250, it means 250 rupees, and this amount is converted into words such as 'Two Hundred Fifty rupees.

In SAP ABAP, use amount-to-word conversion in different places as per the client's requirements. Nowadays, more clients require the total amount to be converted into words. In SAP ABAP, different function modules are used to perform this type of conversion. Below are some examples of these conversions.

Example - 1 :

HR_IN_CHG_INR_WRDS Function Module to convert Amount In Words

In this example, the user enters an amount as a number, and the output shows both the user-entered amount and the converted amount in words.

DATA: WORD TYPE CHAR100.

PARAMETERS NUMBER TYPE PC207-BETRG.
NUMBER = '2378'.

CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
    EXPORTING
      AMT_IN_NUM = NUMBER
    IMPORTING
      AMT_IN_WORDS = WORD
    EXCEPTIONS
      DATA_TYPE_MISMATCH = 1
      OTHERS = 2 .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

write: 'Number: ',number,/,'In Word: ',word.

Output:
Number: 2378
In Word: two thousand three hundred seventy-eight

Explanation:
In this example, the keyword 'Number' is a variable that stores an amount you want to convert, and the data type of this variable is PC207-BETRG. The keyword 'Word' is a variable that stores the converted amount in words, and the data type of this variable is char or string. If you declare another data type, you may encounter error messages or dumps.

Note: This Function module works only for Indian currency conversion. If you want to convert another country's currency, follow the next example.

Example - 2 :

If you want to convert amounts in any currency, such as USD, INR, or EUR, use this function module.

SPELL_AMOUNT Function Module to convert Amount In Words

In this example, the user enters an amount as a number, a billing document number, and a billing date. The output shows the converted amount in words.

tables: vbrk.
DATA: IN_WORDS TYPE SPELL,
          LV_AW         TYPE CHAR100. ""final output store in the variable

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: so_fkdat FOR vbrk-fkdat,
                                so_vbeln FOR vbrk-vbeln.
SELECTION-SCREEN END OF BLOCK b1.

select single vbeln,fkdat,waerk into @data(wa_vbrk) from vbrk where vbeln in @so_vbeln and fkdat in @so_fkdat.
IF sy-subrc = 0.

CALL FUNCTION 'SPELL_AMOUNT' """" TO CONVERT AMOUNT INTO WORDS """""
     EXPORTING
          AMOUNT = '3120.56' " Amount or Total Amount
         CURRENCY = WA_VBRK-WAERK " Currency key
         LANGUAGE = SY-LANGU
     IMPORTING
         IN_WORDS = IN_WORDS
     EXCEPTIONS
         NOT_FOUND = 1
         TOO_LARGE = 2
        OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

IF WA_VBRK-WAERK = 'EUR' .
CONCATENATE IN_WORDS-WORD 'Euro and' IN_WORDS-DECWORD 'Cents Only' INTO LV_AW SEPARATED BY SPACE.
ELSEIF WA_VBRK-WAERK = 'USD' .
CONCATENATE IN_WORDS-word 'Dollar and' IN_WORDS-DECWORD 'Cents Only' INTO LV_AW SEPARATED BY space.
ELSEIF WA_VBRK-WAERK = 'INR' .
CONCATENATE IN_WORDS-WORD 'Rupees and' IN_WORDS-DECWORD 'Paisa Only' INTO LV_AW SEPARATED BY SPACE.
ELSEIF WA_VBRK-WAERK = 'GBP' .
CONCATENATE IN_WORDS-WORD 'Pounds and' IN_WORDS-DECWORD 'Pence Only' INTO LV_AW SEPARATED BY SPACE.
ELSEIF WA_VBRK-WAERK = 'MYR' .
CONCATENATE IN_WORDS-WORD 'Ringgit and' IN_WORDS-DECWORD 'Cents Only' INTO LV_AW SEPARATED BY SPACE.
ELSEIF WA_VBRK-WAERK = 'AUD' .
CONCATENATE IN_WORDS-WORD 'Aussie and' IN_WORDS-DECWORD 'Cents Only' INTO LV_AW SEPARATED BY SPACE.
ENDIF.

ENDIF.
write : 'Amount in word is ', LV_AW.

Output:
Assume the Currency key = USD
This program uses AMOUNT = '3120.56'

Amount in words: three thousand one hundred twenty Dollars and fifty-six Cents Only

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top