在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.

最新文章

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

热门文章

  1. 序列化之Serializer类与ModelSerializer类的使用
  2. c++中的类和对象_概念
  3. Mysql学习day1
  4. golang内存对齐分析(转载)
  5. docker基础_网络模式
  6. 认识 vh 和 vw 单位
  7. 安装黑苹果 、 Mac OS虚拟机
  8. 攻防世界-MISC:can_has_stdio?
  9. Halo 开源项目学习(七):缓存机制
  10. 面试突击44:volatile 有什么用?