• ABAP 数值转换大写


    转自:http://www.dasunny.com/wordpress/sapnotes/2015113091.html
    SAP标准的数值转换函数 SPELL_AMOUNT,
    仅对整数部分进行了处理,小数部分未处理。
    FUNCTION Z_RMBDX.
    DATA: BEGIN OF RMB,
    BY TYPE C,
    SY TYPE C,
    Y TYPE C,
    QW TYPE C,
    BW TYPE C,
    SW TYPE C,
    W TYPE C,
    Q TYPE C,
    B TYPE C,
    S TYPE C,
    G TYPE C,
    D TYPE C,
    J TYPE C,
    F TYPE C,
    N TYPE C,
    END OF RMB.
    DATA: BEGIN OF RMBDX,
    BY(2) TYPE C,
    BY1(4) TYPE C,
    SY(2) TYPE C,
    SY1(4) TYPE C,
    Y(2) TYPE C,
    Y1(2) TYPE C,
    QW(2) TYPE C,
    QW1(4) TYPE C,
    BW(2) TYPE C,
    BW1(4) TYPE C,
    SW(2) TYPE C,
    SW1(4) TYPE C,
    W(2) TYPE C,
    W1(4) TYPE C,
    Q(2) TYPE C,
    Q1(4) TYPE C,
    B(2) TYPE C,
    B1(4) TYPE C,
    S(2) TYPE C,
    S1(4) TYPE C,
    G(2) TYPE C,
    D(2) TYPE C,
    J(2) TYPE C,
    J1(2) TYPE C,
    F(2) TYPE C,
    F1(2) TYPE C,
    Z(2) TYPE C,
    END OF RMBDX.
    DATA: Y(1) TYPE C.
    
    RMB = RMBXX.
    
    IF NOT ( RMB-BY IS INITIAL ) AND RMB-BY NE '0'.
    PERFORM DX USING RMB-BY CHANGING RMBDX-BY.
    
    Y = 'X'.
    
    IF RMB-BY NE '0'.
    IF RMB-SY EQ '0' AND RMB-Y EQ '0'.
    RMBDX-BY1 = '佰亿'.
    ELSE.
    RMBDX-BY1 = ''.
    ENDIF.
    ENDIF.
    ENDIF.
    
    IF NOT ( RMB-SY IS INITIAL ).
    IF RMB-SY NE '0' OR RMB-Y NE '0'.
    PERFORM DX USING RMB-SY CHANGING RMBDX-SY.
    Y = 'X'.
    IF RMB-SY NE '0'.
    IF RMB-Y EQ '0'.
    RMBDX-SY1 = '拾亿'.
    ELSE.
    RMBDX-SY1 = ''.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    IF NOT ( RMB-Y IS INITIAL ).
    IF RMB-Y NE '0' OR RMB-QW NE '0'.
    PERFORM DX USING RMB-Y CHANGING RMBDX-Y.
    Y = 'X'.
    IF RMB-Y NE '0'.
    RMBDX-Y1 = '亿'.
    ENDIF.
    ENDIF.
    ENDIF.
    IF NOT ( RMB-QW IS INITIAL ).
    IF RMB-QW NE '0' OR RMB-BW NE '0'.
    PERFORM DX USING RMB-QW CHANGING RMBDX-QW.
    Y = 'X'.
    IF RMB-QW NE '0'.
    IF RMB-BW EQ '0' AND RMB-SW EQ '0' AND RMB-W EQ '0'.
    RMBDX-QW1 = '仟万'.
    ELSE.
    RMBDX-QW1 = ''.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    IF NOT ( RMB-BW IS INITIAL ).
    IF RMB-BW NE '0' OR RMB-SW NE '0'.
    PERFORM DX USING RMB-BW CHANGING RMBDX-BW.
    Y = 'X'.
    IF RMB-BW NE '0'.
    IF RMB-SW EQ '0' AND RMB-W EQ '0'.
    RMBDX-BW1 = '佰万'.
    ELSE.
    RMBDX-BW1 = ''.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    IF NOT ( RMB-SW IS INITIAL ).
    IF RMB-SW NE'0' OR RMB-W NE '0'.
    PERFORM DX USING RMB-SW CHANGING RMBDX-SW.
    Y = 'X'.
    IF RMB-SW NE '0'.
    IF RMB-W EQ '0'.
    RMBDX-SW1 = '拾万'.
    ELSE.
    RMBDX-SW1 = ''.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    IF NOT ( RMB-W IS INITIAL ).
    IF RMB-W NE '0' OR RMB-Q NE '0'.
    PERFORM DX USING RMB-W CHANGING RMBDX-W.
    Y = 'X'.
    IF RMB-W NE '0'.
    RMBDX-W1 = ''.
    ENDIF.
    ENDIF.
    ENDIF.
    IF NOT ( RMB-Q IS INITIAL ).
    IF RMB-Q NE '0' OR RMB-B NE '0'.
    PERFORM DX USING RMB-Q CHANGING RMBDX-Q.
    Y = 'X'.
    IF RMB-Q NE '0'.
    RMBDX-Q1 = ''.
    ENDIF.
    ENDIF.
    ENDIF.
    IF NOT ( RMB-B IS INITIAL ).
    IF RMB-B NE '0' OR RMB-S NE '0'.
    PERFORM DX USING RMB-B CHANGING RMBDX-B.
    Y = 'X'.
    IF RMB-B NE '0'.
    RMBDX-B1 = ''.
    ENDIF.
    ENDIF.
    ENDIF.
    IF NOT ( RMB-S IS INITIAL ).
    IF RMB-S NE'0' OR RMB-G NE '0'.
    PERFORM DX USING RMB-S CHANGING RMBDX-S.
    Y = 'X'.
    IF RMB-S NE '0'.
    RMBDX-S1 = ''.
    ENDIF.
    ENDIF.
    ENDIF.
    IF NOT ( RMB-G IS INITIAL ) AND RMB-G NE '0'.
    PERFORM DX USING RMB-G CHANGING RMBDX-G.
    Y = 'X'.
    ENDIF.
    IF Y EQ 'X'.
    RMBDX-D = ''.
    ENDIF.
    IF NOT ( RMB-J IS INITIAL ) AND RMB-J NE '0'.
    PERFORM DX USING RMB-J CHANGING RMBDX-J.
    RMBDX-J1 = ''.
    ENDIF.
    IF NOT ( RMB-F IS INITIAL ) AND RMB-F NE '0'.
    PERFORM DX USING RMB-F CHANGING RMBDX-F.
    RMBDX-F1 = ''.
    ELSE.
    RMBDX-Z = ''.
    ENDIF.
    CONDENSE RMBDX NO-GAPS.
    IF RMBXX = 0.
    CLEAR RMBDX.
    ENDIF.
    RMBDX1 = RMBDX.
    CLEAR Y.
    
    ENDFUNCTION.
    
    FORM DX USING VALUE(X) CHANGING DXX.
    CASE X.
    WHEN '0'.
    DXX = ''.
    WHEN '1'.
    DXX = ''.
    WHEN '2'.
    DXX = ''.
    WHEN '3'.
    DXX = ''.
    WHEN '4'.
    DXX = ''.
    WHEN '5'.
    DXX = ''.
    WHEN '6'.
    DXX = ''.
    WHEN '7'.
    DXX = ''.
    WHEN '8'.
    DXX = ''.
    WHEN '9'.
    DXX = ''.
    ENDCASE.
    ENDFORM.
  • 相关阅读:
    java执行shell命令,chmod 777 xxx,改变权限无效的解决办法。
    SpringBoot配置双数据源(一个项目同时连接操作两台数据库)
    《机器学习》周志华西瓜书习题参考答案:第2章
    《机器学习》周志华西瓜书学习笔记(二):模型评估与选择
    只用一套解决方案,就可解决80%的交通物流行业信息难题
    原码、反码、补码
    400+节点的Elasticsearch集群运维
    史上最全PostgreSQL体系结构
    IDEA创建JAVAFX并打包成exe
    DB2 Zos 浅谈
  • 原文地址:https://www.cnblogs.com/rainysblog/p/6632764.html
Copyright © 2020-2023  润新知