SAP BDC 调用中 金额格式转换
2024-08-31 07:41:02
在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.
最新文章
- ORACLE LINUX 6.3 + ORACLE 11.2.0.3 RAC + VBOX安装文档
- ios项目里扒出来的json文件
- 一个简单的Object Hook的例子(win7 32bit)
- day5--<;装饰器、模块、字符串格式化、生成器、迭代器>;logging模块
- List<;T>;线性查找和二分查找BinarySearch效率分析
- 深入理解java虚拟机(6)---内存模型与线程 &; Volatile
- 爪哇国新游记之三十四----Dom4j的XPath操作
- nodejs和mongodb实践
- 引入的iframe是跨域的, 如何控制其高度
- 【转】SendMessage及WPRAME、LPARAME
- 实例:用jQuery实现垂直和水平下拉 菜单
- 使用vs中的工具进行架构比较
- 再探vim经常使用命令
- excel中自动变为插入语句的写法
- SignalR网页实时推送
- javascript中filter的用法
- oracle之数据恢复(delete误删)
- `ifdef、`else、`endif 用法
- (整理)SQL Server 2008 CDC 功能使用
- 【手记】.net正则行尾匹配符$的问题