ABAP更新交货单交货数量和拣配数量
Posted SAP剑客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ABAP更新交货单交货数量和拣配数量相关的知识,希望对你有一定的参考价值。
需求:
Demo:
*&---------------------------------------------------------------------*
*& Report ZTEST_VL02N_DELIVERY1122
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZTEST_VL02N_DELIVERY1122.
DATA: LS_VBKOK TYPE VBKOK.
DATA: LT_VBKOK TYPE STANDARD TABLE OF VBKOK.
DATA: LT_PROTT TYPE STANDARD TABLE OF PROTT.
DATA: LS_PROTT TYPE PROTT.
DATA: LT_VBPOK TYPE STANDARD TABLE OF VBPOK.
DATA: LS_VBPOK TYPE VBPOK.
DATA: LV_MESSAGE TYPE STRING.
DATA: LV_ALL_MESSAGE TYPE STRING.
DATA: LV_FLAG TYPE CHAR01.
PARAMETERS : P_VBELN TYPE LIKP-VBELN OBLIGATORY.
LS_VBKOK-VBELN_VL = P_VBELN.
LS_VBKOK-KOMUE = 'X'. "交货数量 = 捡配数量
LS_VBKOK-KZKODAT = 'X'. "Picking date
LS_VBKOK-KODAT = '20210808'. "Picking date
DATA : LT_LIPS LIKE TABLE OF LIPS WITH HEADER LINE.
SELECT * FROM LIPS
INTO TABLE LT_LIPS
WHERE VBELN = P_VBELN.
LOOP AT LT_LIPS.
CLEAR:LS_VBPOK,LV_FLAG,LV_MESSAGE,LV_ALL_MESSAGE,LT_PROTT.
LS_VBPOK-VBELN_VL = LT_LIPS-VBELN.
LS_VBPOK-POSNR_VL = LT_LIPS-POSNR.
LS_VBPOK-VBELN = LT_LIPS-VGBEL.
LS_VBPOK-POSNN = LT_LIPS-VGPOS.
LS_VBPOK-PIKMG = '4.7'.
LS_VBPOK-MATNR = LT_LIPS-MATNR.
LS_VBPOK-CHARG = LT_LIPS-CHARG.
LS_VBPOK-VRKME = LT_LIPS-VRKME.
LS_VBPOK-MEINS = LT_LIPS-MEINS.
LS_VBPOK-UMVKZ = LT_LIPS-UMVKZ.
LS_VBPOK-UMVKN = LT_LIPS-UMVKN.
LS_VBPOK-LGORT = LT_LIPS-LGORT.
APPEND LS_VBPOK TO LT_VBPOK.
ENDLOOP.
CALL FUNCTION 'WS_DELIVERY_UPDATE'
EXPORTING
VBKOK_WA = LS_VBKOK
* COMMIT = CON
DELIVERY = P_VBELN
UPDATE_PICKING = 'X'
SYNCHRON = 'X'
NICHT_SPERREN = 'X'
TABLES
VBPOK_TAB = LT_VBPOK
PROT = LT_PROTT
EXCEPTIONS
ERROR_MESSAGE = 1
OTHERS = 2.
IF SY-SUBRC = 0 .
LOOP AT LT_PROTT INTO LS_PROTT WHERE MSGTY CA 'EAX'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
MSGID = LS_PROTT-MSGID
MSGNR = LS_PROTT-MSGNO
MSGV1 = LS_PROTT-MSGV1
MSGV2 = LS_PROTT-MSGV2
MSGV3 = LS_PROTT-MSGV3
MSGV4 = LS_PROTT-MSGV4
IMPORTING
MESSAGE_TEXT_OUTPUT = LV_MESSAGE.
CONCATENATE LV_ALL_MESSAGE LV_MESSAGE INTO LV_ALL_MESSAGE .
LV_MESSAGE = LV_ALL_MESSAGE.
LV_FLAG = 'X' .
CLEAR LS_PROTT.
ENDLOOP.
ELSE.
CLEAR LV_MESSAGE.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
MSGID = SY-MSGID
MSGNR = SY-MSGNO
MSGV1 = SY-MSGV1
MSGV2 = SY-MSGV2
MSGV3 = SY-MSGV3
MSGV4 = SY-MSGV4
IMPORTING
MESSAGE_TEXT_OUTPUT = LV_ALL_MESSAGE.
LV_MESSAGE = LV_ALL_MESSAGE.
LV_FLAG = 'X' .
ENDIF .
IF LV_FLAG IS INITIAL .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
WRITE : 'OK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
WRITE : LV_ALL_MESSAGE.
ENDIF.
函数”WS_DELIVERY_UPDATE“还是挺有用,也可以直接交货过账。
以上是关于ABAP更新交货单交货数量和拣配数量的主要内容,如果未能解决你的问题,请参考以下文章