金额大写

作者: Mmm_余安 | 来源:发表于2017-04-24 17:32 被阅读13次

    data: SUMMY TYPE DMBTR VALUE 178,"赋值
    G_CHAR17 type CHAR17.

    G_CHAR17 = ''.
    G_CHAR17 = ABS( SUMMY ).

    CONDENSE G_CHAR17.

    TYPES: CUR6 TYPE P DECIMALS 6 ,
    CUR2 TYPE P DECIMALS 2 .
    DATA VA1 TYPE CUR2.
    DATA STR(40) TYPE C .
    VA1 = G_CHAR17.

    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 = VA1 * 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.
    ENDIF.
    DIGIT = RULE1+D3(1) .
    C3 = ( C1 - 1 ) .
    WEIGHT = RULE2+C3(1) .
    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 = ''.
    ENDIF.
    ENDIF.
    CONCATENATE DIGIT WEIGHT RES INTO RES .
    D1 = D2.
    ENDDO.
    ENDIF.
    LEN = STRLEN( RES ) - 1.
    FEN = RES+LEN(1).
    IF FEN = '元'.
    CONCATENATE RES '整' INTO STR.
    ELSE.
    STR = RES.
    ENDIF.

    G_CHAR17 = STR.

    WRITE:/ G_CHAR17.

    相关文章

      网友评论

        本文标题:金额大写

        本文链接:https://www.haomeiwen.com/subject/xuvpzttx.html