首页 > 其他分享 >SAP ABAP 金额转换大写函数

SAP ABAP 金额转换大写函数

时间:2022-10-19 11:11:52浏览次数:53  
标签:CONCATENATE ss INTO 大写 ELSE ABAP ENDIF SAP dxstr

 

 

  1 DATA: zs(15).
  2   DATA: xs(15).
  3   DATA: str(30).
  4   DATA: len TYPE i VALUE 0.
  5   DATA: cis TYPE i VALUE 0.
  6   DATA: ss(2).
  7   DATA: rr(1).
  8   DATA: strr(15).
  9   DATA: change(30) TYPE c VALUE  '1壹2贰3叁4肆5伍6陆7柒8捌9玖0零'.
 10 *data dxstr(80).
 11   CLEAR dxstr.
 12   MOVE val TO str.
 13   SHIFT str LEFT DELETING LEADING space.
 14   SHIFT str LEFT DELETING LEADING '0'.
 15   SPLIT str AT '.' INTO zs xs.
 16   len = strlen( zs ).  CLEAR strr.  cis = len - 1.
 17   DO len TIMES.
 18     MOVE zs+cis(1) TO rr.
 19     CONCATENATE strr rr INTO strr.
 20     cis = cis - 1.
 21   ENDDO.
 22   cis = 0.
 23   DO len TIMES.
 24     MOVE strr+cis(1) TO ss.
 25     TRANSLATE ss USING change.
 26     CASE cis.
 27       WHEN 0.
 28         IF ss = '零'.
 29           CONCATENATE '元' dxstr INTO dxstr.
 30         ELSE.
 31           CONCATENATE ss '元' dxstr INTO dxstr.
 32         ENDIF.
 33       WHEN 1.
 34         IF ss = '零'.
 35           CONCATENATE ss dxstr INTO dxstr.
 36         ELSE.
 37           CONCATENATE ss '拾' dxstr INTO dxstr.
 38         ENDIF.
 39       WHEN 2.
 40         IF ss = '零'.
 41           CONCATENATE ss dxstr INTO dxstr.
 42         ELSE.
 43           CONCATENATE ss '佰' dxstr INTO dxstr.
 44         ENDIF.
 45       WHEN 3.
 46         IF ss = '零'.
 47           CONCATENATE ss dxstr INTO dxstr.
 48         ELSE.
 49           CONCATENATE ss '仟' dxstr INTO dxstr.
 50         ENDIF.
 51       WHEN 4.
 52         IF ss = '零'.
 53           CONCATENATE '万' dxstr INTO dxstr.
 54         ELSE.
 55           CONCATENATE ss '万' dxstr INTO dxstr.
 56         ENDIF.
 57       WHEN 5.
 58         IF ss = '零'.
 59           CONCATENATE ss dxstr INTO dxstr.
 60         ELSE.
 61           CONCATENATE ss '拾' dxstr INTO dxstr.
 62         ENDIF.
 63       WHEN 6.
 64         IF ss = '零'.
 65           CONCATENATE ss dxstr INTO dxstr.
 66         ELSE.
 67           CONCATENATE ss '佰' dxstr INTO dxstr.
 68         ENDIF.
 69       WHEN 7.
 70         IF ss = '零'.
 71           CONCATENATE ss dxstr INTO dxstr.
 72         ELSE.
 73           CONCATENATE ss '仟' dxstr INTO dxstr.
 74         ENDIF.
 75       WHEN 8.
 76         IF ss = '零'.
 77           CONCATENATE '亿' dxstr INTO dxstr.
 78         ELSE.
 79           CONCATENATE ss '亿' dxstr INTO dxstr.
 80         ENDIF.
 81       WHEN 9.
 82         IF ss = '零'.
 83           CONCATENATE ss dxstr INTO dxstr.
 84         ELSE.
 85           CONCATENATE ss '拾' dxstr INTO dxstr.
 86         ENDIF.
 87       WHEN 10.
 88         IF ss = '零'.
 89           CONCATENATE ss dxstr INTO dxstr.
 90         ELSE.
 91           CONCATENATE ss '百' dxstr INTO dxstr.
 92         ENDIF.
 93       WHEN 11.
 94         IF ss = '零'.
 95           CONCATENATE ss dxstr INTO dxstr.
 96         ELSE.
 97           CONCATENATE ss '仟' dxstr INTO dxstr.
 98         ENDIF.
 99     ENDCASE.
100     cis = cis + 1.
101   ENDDO.
102   CLEAR ss.
103   IF xs <> '00'.
104     MOVE xs+0(1) TO ss.
105     TRANSLATE ss USING change.
106     IF ss <> '零'.
107       CONCATENATE dxstr ss '角' INTO dxstr.
108     ENDIF.
109     MOVE xs+1(1) TO ss.
110     TRANSLATE ss USING change.
111     IF ss <> '零'.
112       CONCATENATE dxstr ss '分' INTO dxstr.
113     ENDIF.
114   ELSE.
115     CONCATENATE dxstr '整' INTO dxstr.
116   ENDIF.
117   REPLACE '零零零' WITH '零' INTO dxstr.
118   REPLACE '零零零' WITH '零' INTO dxstr.
119   REPLACE '零零零' WITH '零' INTO dxstr.
120   REPLACE '零零' WITH '零' INTO dxstr.
121   REPLACE '零零' WITH '零' INTO dxstr.
122   REPLACE '零零' WITH '零' INTO dxstr.
123   REPLACE '零万' WITH '万' INTO dxstr.
124   REPLACE '零元' WITH '元' INTO dxstr.
125   REPLACE '零亿' WITH '亿' INTO dxstr.
126   REPLACE '亿万' WITH '亿' INTO dxstr.
127   CONDENSE dxstr NO-GAPS.
128   IF dxstr = '整'.
129     dxstr = ''.
130   ENDIF.
View Code

 

标签:CONCATENATE,ss,INTO,大写,ELSE,ABAP,ENDIF,SAP,dxstr
From: https://www.cnblogs.com/coderfarmer/p/16805522.html

相关文章

  • ABAP中常用的日期处理函数
     1.获取输入日期月份的最后一天:#DATA:lv_dateTYPEsy-datum.CALLFUNCTION'LAST_DAY_OF_MONTHS'EXPORTINGday_in='20140101'"输入日期......
  • ABAP中常用的功能函数
     1.负号前置:#DATAlv_data(6)TYPEcVALUE'12345-'.CALLFUNCTION'CLOI_PUT_SIGN_IN_FRONT'CHANGINGcvalue=lv_data."-12345"2.读取长文......
  • 工作笔记之 SELECT 语句在 SAP ABAP 中的用法总结(上)
    日常开发过程中,最常用的语句可能就是查询语句了。那么如果从数据库表中查询数据呢?答:​​selectfrom​​语句。SELECT的三个部分在OPENSQL中,​​SELECT​​语句可以查......
  • RMB 金额数字转换成大写
    ///<summary>///转换人民币大小金额///</summary>///<paramname="num">金额</param>///<returns>返回大写形式</returns......
  • dd_jsapi
    调用<scriptsetuplang="ts">import{departmentsPicker}from"@/utils/lib/dd";import{ref}from"vue";interfaceDdDepartment{id:number;name:str......
  • ABAP 范围表 range table
    范围表定义:DATAgr_testTYPERANGEOFchar6.做选择屏幕的时候范围选择框默认就是一个范围表范围表内容:通过断点调试可以看到,范围表有4列signoptionlowhigh......
  • 随机生成大写字母,小写字母
    #字母:string.ascii_letters#大写:string.ascii_uppercase#小写:string.ascii_lowercase importstringimportrandomn_int=int(input("请输入随机字母个数:"))......
  • SAP-MM-采购订单含税价实现方式
    在很多企业里,采购跟供应商谈定的价格是含税价。采购订单价格一般都是通过含税价来实现的,但是SAP的标准功能要求采购订单上面输入的价格是一个净价,即不含税价。如果客户不使......
  • ABAP SMARTFORMS和函数_1
                              自定义上传图片       ......
  • 如何更详细查看SAP 系统版本信息
    查看SAP系统的版本信息是每个Basis的基本功,版本信息主要有:NW版本、Kernel版本,ECC版本,S/4版本等。 以下我们就来聊一下如何查看SAP系统的版本:SAPNetWeaver版本NW版本......