外向交货单发货过账BAPI:WS_DELIVERY_UPDATE

主页 » SAP文库 » SD

作者 勇闯天涯的虾客 2014-08-08    1245
原文地址: 外向交货单发货过账BAPI:WS_DELIVERY_UPDATE 作者: SAP-刘梦
*&---------------------------------------------------------------------*
*&外向交货单发货过账
*&---------------------------------------------------------------------*
PARAMETERS : P_VBELN TYPE VBELN . "外向交货单

DATA : G_LIKP LIKE LIKP .
DATA : I_VBKOK TYPE VBKOK .
DATA : LT_LIPS LIKE TABLE OF LIPS WITH HEADER LINE .
DATA : I_VBPOK_TAB TYPE TABLE OF VBPOK WITH HEADER LINE .
DATA ET_PROT LIKE TABLE OF PROTT WITH HEADER LINE .


START-OF-SELECTION .

“获取交货单数据
SELECT SINGLE * INTO G_LIKP FROM LIKP
WHERE VBELN = P_VBELN .

SELECT * INTO TABLE LT_LIPS FROM LIPS
WHERE VBELN = G_LIKP - VBELN .

"-----VL02N--------
I_VBKOK - VBELN_VL = P_VBELN . "<- Delivery number
I_VBKOK - WABUC = 'X' . "<- Automatic PGI
I_VBKOK - WADAT_IST = G_LIKP - BLDAT .

"填充行项目数据
LOOP AT LT_LIPS .
I_VBPOK_TAB - VBELN_VL = P_VBELN . "<- Delivery number
I_VBPOK_TAB - POSNR_VL = LT_LIPS - POSNR .
I_VBPOK_TAB - VBELN = P_VBELN .
I_VBPOK_TAB - POSNN = LT_LIPS - POSNR .
I_VBPOK_TAB - MATNR = LT_LIPS - MATNR . "Material Number
I_VBPOK_TAB - PIKMG = LT_LIPS - LFIMG .

APPEND I_VBPOK_TAB .
ENDLOOP .

CALL FUNCTION 'WS_DELIVERY_UPDATE'
EXPORTING
VBKOK_WA = I_VBKOK
COMMIT = 'X'
DELIVERY = P_VBELN
UPDATE_PICKING = 'X'
TABLES
VBPOK_TAB = I_VBPOK_TAB
PROT = ET_PROT
EXCEPTIONS
ERROR_MESSAGE = 1
OTHERS = 2 .


"bapi没有return表,消息内容在log表PROT中
READ TABLE ET_PROT WITH KEY MSGTY = 'E' .
IF SY - SUBRC <> 0 .
COMMIT WORK AND WAIT .
ENDIF .

"生成的凭证不会在这个函数中输出,需要在mesg中查找

上图是我对2417单子做了多次创建和冲销

本文原始地址:http://sapdoc.cn/sap/theme/607.html

转载请注明出处来自 SAP文库

上一篇

AA固定资产|概述

下一篇

[BAPI_PR_CHANGE/BAPI_REQUISITION_CHANGE]删除及取消删除采购申请