How to convert number value into numeral word?

Viewed 221

I am trying to check if a certain number, e.g. 7845, has any thousands, hundred, or tens, e.g. 7845 has 7 times thousands, 8 times hundreds, 4 times tens.

The program is supposed to then convert the amount of times to a string:

IF ( DMBTR MOD 10000000 ) LE 9.
    DMBTR / 10000000 = lv_tenmillions.
    lv_tenmillions_check = lv_tenmillions MOD 1.
    
    IF lv_tenmillions_check > 0.
     "Convert
   ENDIF.
   
   IF lv_tenmillions_check < 0.
     "ZERO
   ENDIF.
  ENDIF.

The code that I have written would check for tenmillions, thus would check if the MOD of a value with 10000000 is less equal to 9. Is there any function or code that is used in abap to convert the number into letters?

Thank you all in advance!

2 Answers

You can use function module SPELL_AMOUNT:

DATA: lv_spell TYPE spell.

CALL FUNCTION 'SPELL_AMOUNT'
  EXPORTING
    amount    = 123
*   CURRENCY  = ' '
*   FILLER    = ' '
*   LANGUAGE  = SY-LANGU
  IMPORTING
    in_words  = lv_spell
  EXCEPTIONS
    not_found = 1
    too_large = 2
    OTHERS    = 3.

lv_spell-word contains what you need.

use the functional module SPELL_AMOUNT. Or copy it and go to town.

REPORT ZQUICK.
PARAMETERS p_amt type  p LENGTH 8 .
data l_in_words type spell.


call function 'SPELL_AMOUNT'
  EXPORTING
     amount    = p_amt        " Amount/Number to Be Spelled Out
*    currency  = space    " Currency for Amounts, Blank for Numbers
*    filler    = space    " Filler for Padding the Output Field
*    language  = SY-LANGU " Language Indicator
 IMPORTING
     in_words  = l_in_words. " 

write : l_in_words-word.
Related