如果想線上直接轉換支票中英文數字,請到以下頁面。

線上數字直接轉換中英文


SPELL_AMOUNT 可以將數字轉為英文,但對於中文轉換還不成熟。


整數和小數部分需要分開處理,也就是分別調用 SPELL_AMOUNT,再加上 Currency,CENTS 等字串。


Convert Number To words Using ABAP


以下是轉換英文大寫的 function

  1. FORM amount_to_word USING l_amt TYPE fkwrt
  2. l_waers TYPE eban-waers
  3. CHANGING saywords TYPE string.
  4.  
  5. DATA: lw_spell LIKE spell,
  6. lv_text TYPE ltext,
  7. lv_cent TYPE spell.
  8.  
  9. SELECT SINGLE ktext INTO lv_text
  10. FROM tcurt
  11. WHERE spras = 'EN'
  12. AND waers = l_waers.
  13.  
  14. TRANSLATE lv_text TO UPPER CASE.
  15.  
  16. CALL FUNCTION 'SPELL_AMOUNT'
  17. EXPORTING
  18. amount = l_amt
  19. currency = l_waers
  20. filler = ''
  21. language = 'E'
  22. IMPORTING
  23. in_words = lw_spell.
  24.  
  25. lw_spell-decimal = lw_spell-decimal / 10.
  26. IF NOT lw_spell-decimal IS INITIAL.
  27. CALL FUNCTION 'SPELL_AMOUNT'
  28. EXPORTING
  29. amount = lw_spell-decimal
  30. filler = ''
  31. language = 'E'
  32. IMPORTING
  33. in_words = lv_cent.
  34. CLEAR saywords.
  35. IF NOT lv_cent-word IS INITIAL.
  36. CONCATENATE lv_text
  37. lw_spell-word
  38. 'AND' lv_cent-word 'CENTS'
  39. INTO saywords
  40. SEPARATED BY space.
  41. CONCATENATE lv_text lw_spell-="kw9">word
  42. INTO saywords
  43. SEPARATED BY space.
  44.  
  45. CONCATENATE '** SAY'saywords '**'
  46. INTO saywords
  47. SEPARATED BY space.
  48.  
  49. ENDFORM. "amount_to_word


調用方法如下

  1. perform amount_to_word using GS_HD_KOMK-FKWRT "Amount (數字金額)
  2. GS_HD_GEN-BIL_WAERK "Currency (貨幣)
  3. CHANGING GF_AMOUNT_WORD. "Spell Amount (轉換後的英文)

其它你可能會有興趣的文章

Share