作者:edwin
*&---------------------------------------------------------------------*
*& Report Z_BARRY_CONV_AMOUNT *
*& *
*&---------------------------------------------------------------------*
*& 金额大写转换 *
*&---------------------------------------------------------------------*
REPORT Z_BARRY_CONV_AMOUNT .
TYPES: CUR6 TYPE P DECIMALS 6 ,
CUR2 TYPE P DECIMALS 2 .
DATA VA1 TYPE CUR2.
DATA STR(40) TYPE C .
VA1 = '232.23'. PERFORM CONV_AMOUNT USING VA1
CHANGING STR.
WRITE STR.
*&--------------------------------------------------------------------*
*& Form conv_amount
*&--------------------------------------------------------------------*
FORM CONV_AMOUNT USING VALUE(F_SOURCE)
CHANGING VALUE(F_RESULT).
DATA: SCR(30) TYPE C, RES(60) TYPE C,FEN(2) TYPE C .
DATA: LEN TYPE I, C1 TYPE I, C2 TYPE I, C3 TYPE I, C4 TYPE I.
DATA: D1(1) TYPE C, D2(1) TYPE C, D3 TYPE I.
DATA: DIGIT(2) TYPE C, WEIGHT(2) TYPE C.
DATA: RULE1(20) TYPE C VALUE '零壹贰叁肆伍陆柒捌玖'.
DATA: RULE2(30) TYPE C VALUE '分角元拾佰仟万拾佰仟亿拾佰仟万'.
SCR = F_SOURCE * 100.
CONDENSE SCR NO-GAPS.
IF SCR = '0'.
RES = '零元'.
ELSE.
LEN = STRLEN( SCR ).
C1 = 0.
D1 = '0'.
CLEAR RES.
DO LEN TIMES.
C1 = C1 + 1.
C2 = LEN - C1.
D2 = SCR+C2(1) .
IF D2 = '0'.
D3 = 0.
ELSE.
D3 = D2 * 2.
ENDIF.
DIGIT = RULE1+D3(2) .
C3 = ( C1 - 1 ) * 2.
WEIGHT = RULE2+C3(2) .
IF D2 = '0'.
IF C1 = 3.
DIGIT = ''.
ELSEIF C1 = 7.
DIGIT = ''.
IF LEN > 10 .
C4 = LEN - 10.
IF SCR+C4(4) = '0000'.
WEIGHT = ''.
ENDIF.
ENDIF.
ELSEIF C1 = 11.
DIGIT = ''.
ELSEIF D1 = '0'.
DIGIT = ''.
WEIGHT = ''.
ELSE.
WEIGHT = ''.