效果
输入参数
输出参数
源代码
FUNCTION ZF_CN_NUM2.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" REFERENCE(I_JE) TYPE BSEG-DMBTR
*" EXPORTING
*" REFERENCE(E_JE) TYPE CHAR100
*"----------------------------------------------------------------------
DATA:s_zs TYPE spell,
s_j TYPE spell,
s_f TYPE spell,
v_nu TYPE char30,
v_zs TYPE char30,
v_xs TYPE char30,
v_j TYPE char30,
v_f TYPE char30.
v_nu = i_je.
SPLIT v_nu AT '.' INTO v_zs v_xs.
v_j = v_xs(1).
v_f = v_xs+1(1).
IF v_zs <> '0' .
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
language = '1' "sy-langu"
currency = sy-waers
amount = v_zs
filler = ' '
IMPORTING
in_words = s_zs.
ENDIF.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
language = '1' "sy-langu"
currency = sy-waers
amount = v_j
filler = ' '
IMPORTING
in_words = s_j.
IF v_f <> '0' .
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
language = '1' "sy-langu"
currency = sy-waers
amount = v_f
filler = ' '
IMPORTING
in_words = s_f.
ENDIF.
IF s_j-word = '零' AND s_f IS INITIAL . "如果没有小数位数 如 11.00"
CONCATENATE s_zs-word '元整' INTO e_je.
ELSEIF s_zs IS INITIAL . "如果没有整数位 如 0.10 0.01 0.11"
IF s_j-word <> '零' .
CONCATENATE s_j-word '角' INTO e_je .
ENDIF.
IF s_f IS NOT INITIAL.
CONCATENATE e_je s_f-word '分' INTO e_je.
ENDIF.
ELSE. "如果整数小数位都有 如 11.01 11.10 11.11"
CONCATENATE s_zs-word '元' INTO e_je.
IF s_j-word = '零' AND s_f IS NOT INITIAL .
CONCATENATE e_je s_j-word INTO e_je.
ELSE.
CONCATENATE e_je s_j-word '角' INTO e_je .
ENDIF.
IF s_f IS NOT INITIAL .
CONCATENATE e_je s_f-word '分' INTO e_je.
ENDIF.
ENDIF.
ENDFUNCTION.