当前位置:网站首页>SAP VL02N 交货单过账函数 WS_DELIVERY_UPDATE
SAP VL02N 交货单过账函数 WS_DELIVERY_UPDATE
2022-07-28 22:36:00 【请输入昵称膨胀的馒头】
SAP VL02N 交货单过账函数 WS_DELIVERY_UPDATE
前言
用BDC模拟VL02N过账也可以,并不复杂
只不过用SAP提供的Function Module在扩展性上要好一些
代码总览
测试报表
TABLES: likp.
DATA: gs_likp TYPE likp,
gt_lips TYPE STANDARD TABLE OF lips,
gs_lips TYPE lips,
gs_return TYPE zcommon_return.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: s_vbeln FOR likp-vbeln MEMORY ID vbe.
SELECTION-SCREEN END OF BLOCK blk1.
START-OF-SELECTION.
SELECT SINGLE * FROM likp WHERE vbeln IN @s_vbeln INTO CORRESPONDING FIELDS OF @gs_likp.
gs_likp-wadat_ist = gs_likp-wadat.
SELECT * FROM lips WHERE vbeln IN @s_vbeln INTO CORRESPONDING FIELDS OF TABLE @gt_lips.
CALL FUNCTION 'ZSDFM01_DELIVERY'
EXPORTING
wa_likp = gs_likp
IMPORTING
wa_return = gs_return
TABLES
it_lips = gt_lips.
WRITE gs_return.
END-OF-SELECTION.
FM ZSDFM01_DELIVERY
FUNCTION zsdfm01_delivery.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(WA_LIKP) TYPE LIKP
*" EXPORTING
*" VALUE(WA_RETURN) TYPE ZCOMMON_RETURN
*" TABLES
*" IT_LIPS STRUCTURE LIPS
*"----------------------------------------------------------------------
DATA: wa_lips LIKE LINE OF it_lips,
wa_vbkok TYPE vbkok.
DATA: it_vbpok TYPE STANDARD TABLE OF vbpok,
wa_vbpok TYPE vbpok.
DATA: it_prott TYPE STANDARD TABLE OF prott,
wa_prott TYPE prott.
DATA: v_msg TYPE string.
LOOP AT it_lips INTO wa_lips.
CLEAR:wa_vbpok.
wa_vbpok = VALUE #( vbeln_vl = wa_lips-vbeln
posnr_vl = wa_lips-posnr
vbeln = wa_lips-vgbel
posnn = wa_lips-vgpos
matnr = wa_lips-matnr
lgort = wa_lips-lgort
lfimg = wa_lips-lfimg
lgmng = wa_lips-lfimg " 以仓库保管单位级的实际交货数量
pikmg = wa_lips-lfimg " 参考数量以基本计量单位计算
).
APPEND wa_vbpok TO it_vbpok.
ENDLOOP.
wa_vbkok = VALUE #( vbeln_vl = wa_likp-vbeln
wadat_ist = wa_likp-wadat_ist " 实际货物移动日期
wabuc = 'X' " 自动过帐货物移动
komue = 'X' " 自动以拣配数量覆盖交货数量
).
CALL FUNCTION 'WS_DELIVERY_UPDATE'
EXPORTING
vbkok_wa = wa_vbkok
commit = 'X'
delivery = wa_likp-vbeln
update_picking = 'X'
TABLES
vbpok_tab = it_vbpok
prot = it_prott.
DELETE it_prott WHERE msgty NE 'E' AND msgty NE 'A'.
IF it_prott IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
wa_return-mtype = 'S'.
wa_return-mtext = '过账成功!' .
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
LOOP AT it_prott INTO wa_prott.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = wa_prott-msgid
msgnr = wa_prott-msgno
msgv1 = wa_prott-msgv1
msgv2 = wa_prott-msgv2
msgv3 = wa_prott-msgv3
msgv4 = wa_prott-msgv4
IMPORTING
message_text_output = v_msg.
wa_return-mtext = wa_return-mtext && '过账失败! 原因如下:' && v_msg .
ENDLOOP.
wa_return-mtype = 'E'.
ENDIF.
ENDFUNCTION.
代码解析
没什么好分析的,vbpok 类型中的字段和 lips 表的字段差不多
代表需要过账的明细行
需要关注的是抬头数据 vbkok 中实际货物移动日期 wadat_ist 和 wabuc 自动过账货物移动需要给到值
wadat_ist = wa_likp-wadat_ist " 实际货物移动日期
wabuc = 'X' " 自动过帐货物移动
然后FM WS_DELIVERY_UPDATE的传入需要设置参数 commit 和 update_picking
这两个参数的默认值都为空,需要设置为 abap_true
commit = 'X'
update_picking = 'X'
调用FM过账后,获取 prot 的返回值
it_prott 里会存储错误信息
通过FM MESSAGE_TEXT_BUILD来获取文本内容
最后输出
结语
如果本文对你有所帮助请为它点个赞吧
边栏推荐
- Introduction and solution of common security vulnerabilities in Web System SQL injection
- Locally connect to redis on Windows Server
- 动态规划问题(一)
- Software designer afternoon question
- Concurrency in go
- Attack and defense world web master advanced area web_ php_ include
- 动态规划问题(八)
- With this, your messages can't be monitored
- 动态规划问题(四)
- Still writing a lot of if to judge? A rule executor kills all if judgments in the project
猜你喜欢

Event extraction and documentation (2008-2017)

With this, your messages can't be monitored

Introduction and solution of common security vulnerabilities in web system CSRF attack

Attack and defense world web master advanced area web_ php_ unserialize

flyway的快速入门教程

Feign call fails. JSON parse error illegal character ((ctrl-char, code 31)) only regular white space (R

Advanced area of attack and defense world web masters ics-06

What are the skills of API interface optimization?

I don't know how lucky the boy who randomly typed the log is. There must be a lot of overtime!

feign调用不通问题,JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
随机推荐
MQ 消息丢失、重复、积压问题,如何解决?
CV semantic segmentation model sketch (2)
"Method not allowed", 405 problem analysis and solution
Redis learning notes
Oracle超全SQL,细节狂魔
Plato farm is expected to further expand its ecosystem through elephant swap
Sword finger offer 64. find 1+2+... +n, logical operator short circuit effect
时间序列统计分析
Oracle实例无法启动的问题如何解决
Multimodal model sketch (1)
IDEA 连接 数据库
feign调用不通问题,JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r
Alibaba Code代码索引技术实践:为Code Review提供本地IDE的阅读体验
手把手教你安装Latex(保姆级教程)
PTA (daily question) 7-70 diamond
@PostConstruct注解详解
Install mysql5.7 under Linux, super detailed complete tutorial, and cloud MySQL connection
乱打日志的男孩运气怎么样我不知道,加班肯定很多!
动态规划问题(五)
Advanced area of attack and defense world web masters training www robots