数字金额转换中文金额

效果
在这里插入图片描述

输入参数
在这里插入图片描述
输出参数
在这里插入图片描述
源代码

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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值