SAP has provided Function Modules to achieve this.
1. SPELL_AMOUNT - For International Numbering System ( Billions, Millions, Thousand )
2. HR_IN_CHG_INR_WRDS - For the Indian Numbering system ( Crores, Lakhs )
If you want to convert the amount into Millions and Billions use SPELL_AMOUNT.
or if you want to convert the amount in Crores and Lakhs then use HR_IN_CHG_INR_WRDS.
Let's see these FMs in action.
1. SPELL_AMOUNT-
DATA: amnt TYPE DMBTR value '5322478.76' ,
lv_words TYPE SPELL.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
amount = amnt
currency = 'BDT'
* FILLER = ' '
language = sy-langu
IMPORTING
in_words = lv_words
EXCEPTIONS
not_found = 1
too_large = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
WRITE: lv_words-word, lv_words-decword.
Output:
Here the output we are receiving from the FM is of type 'SPELL' which is a structure to hold the incoming data.
Check the structure below. It holds both the word for the amount and decimal places. You can use them as per your requirement.
2. HR_IN_CHG_INR_WRDS -
DATA: amnt type PC207-BETRG Value '5322478.76',
lv_words(100) type c.
CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
amt_in_num = amnt
IMPORTING
AMT_IN_WORDS = lv_words
EXCEPTIONS
DATA_TYPE_MISMATCH = 1
OTHERS = 2
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
WRITE: lv_words.
Output:
Here the output we are receiving from the FM is of type 'C'. And the Import parameter is of currency type BETRG.
One extra feature it provides is the addition of Rupees and Paise. You can replace it with your local currency words with the Replace Keyword in ABAP.
Replace 'Rupees' with 'TAKA' into lv_words.
I have replaced it with TAKA ( Bangladeshi Currency ).