Import:

IV_MONEY TYPE BF_DMBTR                       按本位币计的金额

Outport:

EV_MONEY

Exceptions:

WRONG_MONEY

Source code:

 FUNCTION ZFUC_NUMERIC_TO_CHINESE.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     REFERENCE(IV_MONEY) TYPE  BF_DMBTR
*"  EXPORTING
*"     REFERENCE(EV_MONEY)
*"  EXCEPTIONS
*"      WRONG_MONEY
*"----------------------------------------------------------------------
IF IV_MONEY = 0.
        EV_MONEY = '零'.
        EXIT.
      ENDIF.
      DATA:MONEY_STR(33).
      MONEY_STR = IV_MONEY.
       CONDENSE MONEY_STR NO-GAPS.
      IF MONEY_STR CN '0123456789. '.
        RAISE WRONG_MONEY.
      ENDIF.
      DATA:I TYPE I.
      IF MONEY_STR CS '.'.
        I = SY-FDPOS + 1.
        MONEY_STR+SY-FDPOS = MONEY_STR+I.
      ENDIF.
      CONDENSE MONEY_STR NO-GAPS.
      DATA:UNITS_OFF TYPE I,
           CURNT_OFF TYPE I.
      DATA:LASTD TYPE N,CURNTD TYPE N.
      DATA:CWORD(2),WEIGHT(2).
      DATA:UNITS(30VALUE '分角元拾佰仟万拾佰仟亿拾佰仟万',
           DIGTS(20VALUE '零壹贰叁肆伍陆柒捌玖'.

*    * clear:ev_money,units_off.
      LASTD = 0.
      CURNT_OFF = STRLEN( MONEY_STR ) - 1.
      WHILE CURNT_OFF >= 0.
        CURNTD = MONEY_STR+CURNT_OFF(1).
        I = CURNTD.
        CWORD = DIGTS+I(1).

        WEIGHT = UNITS+UNITS_OFF(1).

        I = UNITS_OFF / 1.
        IF CURNTD = 0.             "Current digit is 0
          IF I = 2 OR I = 6 OR I = 10.
            CLEAR:CWORD.
            IF CURNT_OFF = 0.
              CLEAR:WEIGHT.
            ENDIF.
          ELSEIF LASTD = 0.
            CLEAR:CWORD,WEIGHT.
          ELSE.
            CLEAR:WEIGHT.
          ENDIF.
        ENDIF.
        CONCATENATE CWORD WEIGHT EV_MONEY INTO EV_MONEY.
        LASTD = CURNTD.
        SUBTRACT 1 FROM CURNT_OFF.
        ADD 1 TO UNITS_OFF.
      ENDWHILE.
      IF EV_MONEY NS '分'.
        CONCATENATE EV_MONEY '整' INTO EV_MONEY.
      ELSE.
        CWORD = EV_MONEY.
        IF CWORD = '零'.
          SHIFT EV_MONEY BY 1 PLACES.
        ENDIF.
      ENDIF.

    ENDFUNCTION.