FUNCTION SPELL_AMOUNT 相关

  转自:http://techlog.hikarulea.com/abap-spell_amount/

 

通过 function module 将金额或数字显示为本地语言

DATA:output_words TYPE spell. CALL FUNCTION ‘SPELL_AMOUNT’ EXPORTING amount = 10 * CURRENCY = ‘ ‘ * FILLER = ‘ ‘ language = sy-langu IMPORTING in_words = output_words EXCEPTIONS not_found = 1 too_large = 2 OTHERS = 3 . IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. WRITE:output_words-dig01,output_words-dig02, / output_words-word.

 

结果:零 壹
         壹 壹 拾

 DATA:amount TYPE p LENGTH 13 DECIMALS 3 VALUE ‘134.73′. CALL FUNCTION ‘SPELL_AMOUNT’ EXPORTING amount = amount * CURRENCY = ‘ ‘ * FILLER = ‘ ‘ language = ‘E’ IMPORTING in_words = output_words EXCEPTIONS not_found = 1 too_large = 2 OTHERS = 3 . IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. WRITE:output_words-dig01,output_words-dig02,output_words-dig03, output_words-dig04,output_words-dig05,output_words-dig06. WRITE:output_words-word.

结果:ZERO    THREE   SEVEN   FOUR    THREE   ONE
         ONE HUNDRED THIRTY-FOUR THOUSAND SEVEN HUNDRED THIRTY

CALL FUNCTION ‘SPELL_AMOUNT’ EXPORTING amount = amount currency = ‘JPY’" type SY-WAERS (报废) table:tcurc * FILLER = ‘ ‘ language = ‘J’ IMPORTING in_words = output_words EXCEPTIONS not_found = 1 too_large = 2 OTHERS = 3 . IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. WRITE:output_words-dig01,output_words-dig02,output_words-dig03, output_words-dig04,output_words-dig05,output_words-dig06. WRITE:output_words-word.

  结果:NULL    DREI    SIEBEN  VIER    DREI    EINS
      ZEHN DREI ZEHNTAUSEND VIER TAUSEND SIEBEN HUNDERT DREI ZEHN

————
注意:
1、结构 SPELL 的 WORD 组件用于输出本地语言显示的数值,但很明显,金额都被放大了,而且还有点混乱。
2、该 function module 会将参数 AMOUNT 的数值(按变量小数点位数)放大为整数后,放入 SPELL 的 NUMBER 组件中。
2、中文和英语都没有问题(dig01-dig15,dil01-dig15)

你可能感兴趣的:(function,Module,table,null,语言,output)