ABAP 金钱数量小写转换成大写详解编程语言

FUNCTION zfi_amount_to_cn. 
*"---------------------------------------------------------------------- 
*"*"本地接口: 
*"  IMPORTING 
*"     REFERENCE(RMBXX) TYPE  WRBTR 
*"  EXPORTING 
*"     REFERENCE(RMBDX1) TYPE  C 
*"---------------------------------------------------------------------- 
  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. 
    rmbdx1 = '零'. 
    CLEAR rmbdx. 
  ENDIF. 
  rmbdx1 = rmbdx. 
  CLEAR y. 
 
ENDFUNCTION.

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/18006.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论