Showing posts with label Amount to Word in ABAP. Show all posts
Showing posts with label Amount to Word in ABAP. Show all posts

Wednesday, March 2, 2022

Function Modules to Convert Amount to Words in ABAP

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-

DATAamnt 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.

WRITElv_words-wordlv_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 - 

DATAamnt          type PC207-BETRG Value '5322478.76',
      lv_words(100type 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.

  WRITElv_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 ). 




How to Find Implemented BADIs for a Tcode in SAP

  Simple way to find implemented BADI for a TCode in SAP  First We have to find the Package for the transaction. 1.      Go to that par...