zoukankan      html  css  js  c++  java
  • 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.
  • 相关阅读:
    ReactNative学习-webView
    React Native学习-将 'screen', 'window' or a view生成图片
    React Native学习-measure测量view的宽高值
    React Native教程
    React Native学习-CameraRoll
    React Native学习-控制横竖屏第三方组件:react-native-orientation
    React Native学习-调取摄像头第三方组件:react-native-image-picker
    ReactNative学习-滑动查看图片第三方组件react-native-swiper
    MFC的简单加法器(二)
    MFC之目录结构及消息流转(一)
  • 原文地址:https://www.cnblogs.com/rainysblog/p/6632764.html
Copyright © 2011-2022 走看看