SAP BDC 调用中 金额格式转换
在BDC调用中,由于用户设置不同,导致金额、日期等字段的输入格式不正确。此处给出 自创 金额转换FM 并配有 调用方式。
function zgm_conver_cuur.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_STRIN)
*" REFERENCE(I_DECIMALS) TYPE I
*" EXPORTING
*" REFERENCE(E_STROUT)
*"----------------------------------------------------------------------
data:l_dcpfm like usr01-dcpfm,
l_strin type char20,
l_reverse type char20,
l_strout type char20,
l_str1 type string,
l_str2 type string, l_mask type string.
data:l_lenth type i.
data:l_lenth2 type i.
clear l_mask.
l_str2 = '___'.
case i_decimals.
when 2.
l_str1 = '__'.
when 3.
l_str1 = '___'.
when 4.
l_str1 = '____'.
when others.
endcase. l_strin = i_strin.
"remove Punctuation by space
replace '.' with '' into l_strin.
condense l_strin no-gaps.
l_lenth = strlen( l_strin ).
l_lenth2 = l_lenth - i_decimals. case l_lenth2.
when 1 or 2 or 3.
when 4 or 5 or 6.
when others.
endcase.
"reverse string
call function 'STRING_REVERSE'
exporting
string = l_strin
lang = sy-langu
importing
rstring = l_reverse. select single dcpfm into l_dcpfm from usr01 where bname = sy-uname. case l_dcpfm.
when ''.
case l_lenth2.
when 1 or 2 or 3.
concatenate l_str1 l_str2 into l_mask separated by ','.
when 4 or 5 or 6.
concatenate l_str2 l_str2 into l_mask separated by '.'.
concatenate l_str1 l_mask into l_mask separated by ','.
when 7 or 8 or 9.
concatenate l_str2 l_str2 l_str2 into l_mask separated by '.'.
concatenate l_str1 l_mask into l_mask separated by ','.
when 10 or 11 or 12.
concatenate l_str2 l_str2 l_str2 l_str2 into l_mask separated by '.'.
concatenate l_str1 l_mask into l_mask separated by ','.
when others.
endcase.
when 'X'.
case l_lenth2.
when 1 or 2 or 3.
concatenate l_str1 l_str2 into l_mask separated by '.'.
when 4 or 5 or 6.
concatenate l_str2 l_str2 into l_mask separated by ','.
concatenate l_str1 l_mask into l_mask separated by '.'.
when 7 or 8 or 9.
concatenate l_str2 l_str2 l_str2 into l_mask separated by ','.
concatenate l_str1 l_mask into l_mask separated by '.'.
when 10 or 11 or 12.
concatenate l_str2 l_str2 l_str2 l_str2 into l_mask separated by ','.
concatenate l_str1 l_mask into l_mask separated by '.'.
when others.
endcase.
when 'Y'.
case l_lenth2.
when 1 or 2 or 3.
concatenate l_str1 l_str2 into l_mask separated by ','.
when 4 or 5 or 6.
concatenate l_str2 l_str2 into l_mask separated by space.
concatenate l_str1 l_mask into l_mask separated by ','.
when 7 or 8 or 9.
concatenate l_str2 l_str2 l_str2 into l_mask separated by space.
concatenate l_str1 l_mask into l_mask separated by ','.
when 10 or 11 or 12.
concatenate l_str2 l_str2 l_str2 l_str2 into l_mask separated by space.
concatenate l_str1 l_mask into l_mask separated by ','.
when others.
endcase.
endcase. write l_reverse using edit mask l_mask to l_strout. if sy-subrc = 0.
"reverse string
call function 'STRING_REVERSE'
exporting
string = l_strout
lang = sy-langu
importing
rstring = e_strout.
endif.
endfunction.
DATA:l_wrbtr LIKE bdcdata-fval. "BDC Amount l_wrbtr = <lfs_post>-kwert. CONDENSE l_wrbtr NO-GAPS. CALL FUNCTION 'ZGM_CONVER_CUUR'
EXPORTING
i_strin = l_wrbtr
i_decimals = 2"两位小数,也可三位 四位
IMPORTING
e_strout = l_wrbtr.
SAP BDC 调用中 金额格式转换的更多相关文章
- JAVA中时间格式转换
1.将任意日期格式的字符串转换为指定格式的字符串 //默认格式 String s1 = "20190110133236"; //给定格式 String s2 = "201 ...
- layui的table中日期格式转换
我使用的layui的2.4.5版本,在util中已经带了格式转换的函数.这里主要记录如何使用. 未使用前在table中显示如下: 前端代码如下: {field:'createDate', title: ...
- SpringBoot+MyBatis Plus对Map中Date格式转换的处理
在 SpringBoot 项目中, 如何统一 JSON 格式化中的日期格式 问题 现在的关系型数据库例如PostgreSQL/MySQL, 都已经对 JSON 类型提供相当丰富的功能, 项目中对于不需 ...
- Sql与C#中日期格式转换总结
SQL中的转换方法: 一.将string转换为datetime,主要是使用Convert方法, 方法,Convert(datetime [ ( length ) ] , expression, [st ...
- Mac中的格式转换如何用读写工具Tuxera NTFS完成
Tuxera NTFS for Mac是一款专门为Mac用户提供的NTFS驱动软件,它不仅可以进行磁盘文件的访问.编辑.传输和存储,还可以对硬盘进行维修检查以及修复. 今天小编就给大家简单介绍一下Tu ...
- Sql Server中Float格式转换字符串varchar方法(转)
1.[Sql Server](70) SELECT CONVERT(varchar(100), CAST(@testFloat AS decimal(38,2)))SELECT STR(@testF ...
- js读取excel中日期格式转换问题
在使用js-xlsx插件来读取excel时,会将2018/10/16这种数据自动装换成48264.12584511. 所以需要自己手动再转换回来 // excel读取2018/01/01这种时间格式是 ...
- JAVA中日期格式转换各个字母代表含义
G Era 标志符 Text AD y 年 Year 1996; 96 M 年中的月份 Month July; Jul; 07 w 年中的周数 Number 27 W ...
- linq中日期格式转换或者比较,程序报错说不支持方法的解决办法
public void TestMethod1(){using (var _context = new hotelEntities()){var rq = DateTime.Now.Date;var ...
随机推荐
- 两数之和_LeetCode_1
LeetCode_1原题链接:https://leetcode-cn.com/problems/two-sum/ 剑指 Offer 57原题链接: https://leetcode-cn.com/pr ...
- 『现学现忘』Git基础 — 3、Git介绍
目录 1.Git的历史 2.Git的特点 3.Git在项目协作开发中所解决的问题 1.Git的历史 Git是目前世界上最先进的分布式版本控制系统,开源.免费. Git 是 Linus (林纳斯)为了帮 ...
- 微信小程序循环列表点击每一个单独添加动画
首先,咱们看一下微信小程序动画怎么实现,我首先想到的是anime.js,但是引入之后用不了,微信小程序内的css也无法做到循环的动态,我就去找官方文档看看有没有相应的方法,哎,还真有 点击这里查看 微 ...
- AOT和单文件发布对程序性能的影响
前言 这里先和大家介绍一下.NET一些发布的历史,以前的.NET框架原生并不支持最终编译结果的单文件发布(需要依赖第三方工具),我这里新建了一个简单的ASP.NET Core项目,发布以后的目录就会像 ...
- Spring Retry 在SpringBoot 中的应用
Spring Boot中使用Spring-Retry重试框架 Spring Retry提供了自动重新调用失败的操作的功能.这在错误可能是暂时的(例如瞬时网络故障)的情况下很有用. 从2.2.0版本开始 ...
- 使用fastai训练的一个性别识别模型
在学习了python中的一些机器学习的相关模块后,再一次开始了深度学习之旅.不过与上次的TensorFlow框架不同,这一次接触的是fast.ai这样一个东西.这个框架还不稳定,网上也没有相关的中文文 ...
- Linux vs Unix - Linux与Unix到底有什么不同?
来自:Linux迷链接:https://www.linuxmi.com/linux-vs-unix.html Linux和Unix这两个术语可以互换地用来指同一操作系统.这在很大程度上是由于他们惊人的 ...
- vue3 vite 系统标题 系统名称统一配置
想要统一配置系统名称 或者其他的,需要在vue3中使用 vite 的环境变量 vite 的环境变量 需要创建两个文件(和 vite.config.js 文件同一目录) .env.development ...
- Apache Shiro 漏洞汇总
Apache Shiro 漏洞汇总 以下是我个人通过收集信息收集起来的一些Apache Shiro漏洞信息,这些漏洞的poc都是公开的,利用起来也是比较简单 Apache Shiro是什么东西: Ap ...
- 在SpringBoot中使用logback优化异常堆栈的输出
一.背景 在我们在编写程序的过程中,无法保证自己的代码不抛出异常.当我们抛出异常的时候,通常会将整个异常堆栈的信息使用日志记录下来.通常一整个异常堆栈的信息是比较多的,而且存在一些没用的信息.那么我们 ...