BAPI for updating the delivery document
WS_DELIVERY_UPDATE - for picking the outbound delivery
The sample code:
WA_VBKOK-VBELN_VL = <del_nbr>.
WA_VBKOK-VBELN = VBFA-VBELV.
LOOP AT TAB_VBPOK.
TAB_VBPOK-VBELN_VL = WA_VBKOK-VBELN_VL.
Get delivery line item data.
TAB_VBPOK-VBELN = SY-DATUM.
TAB_VBPOK-POSNN = SY-UZEIT.
TAB_VBPOK-VBTYP_N = VBFA-VBTYP_N.
SELECT * INTO TABLE TVBFA FROM VBFA
WHERE VBELV = WA_VBKOK-VBELN_VL.
SORT TVBFA DESCENDING.
CLEAR TVBFA.
READ TABLE TVBFA WITH KEY VBELV = TAB_VBPOK-VBELN_VL
POSNV = TAB_VBPOK-POSNR_VL
VBTYP_N = 'Q'
TAQUI = ' '.
IF SY-SUBRC EQ 0.
V_PIKMG = TAB_VBPOK-PIKMG + TVBFA-RFMNG. " Picking quantity
CLEAR TVBFA.
READ TABLE TVBFA WITH KEY VBELV = TAB_VBPOK-VBELN_VL
POSNV = TAB_VBPOK-POSNR_VL
VBTYP_N = 'Q'
TAQUI = 'X'.
IF SY-SUBRC EQ 0.
V_PIKMG = V_PIKMG + TVBFA-RFMNG. " Total Picking quantity
*****Error Message: Picked quantity is larger than the
quantity to be delivered.
IF LIPS-LFIMG LT V_PIKMG.
PERFORM GET_RETURN USING 'E' 'VL' '019' SPACE SPACE SPACE
SPACE
RETURN.
V_EXIT = 'Y'.
EXIT. " EXIT THE RFC.
ENDIF.
ENDIF.
ENDIF.
TAB_VBPOK-KZNTG = 'X'. " Confirmation of net weight
TAB_VBPOK-KZBRG = 'X'. " Confirmation of gross weight
TAB_VBPOK-KZVOL = 'X'. " Confirmation of volume
MODIFY TAB_VBPOK.
ENDLOOP.
CALL FUNCTION 'WS_DELIVERY_UPDATE_2'
EXPORTING
VBKOK_WA = WA_VBKOK
SYNCHRON = 'X'
DELIVERY = WA_VBKOK-VBELN_VL
NICHT_SPERREN_1 = 'X'
IF_ERROR_MESSAGES_SEND = 'X'
IT_PARTNER_UPDATE = IS_PARTNER
TABLES
PROT = I_PROTT.
IF NOT I_PROTT IS INITIAL.
RETURN-TYPE = 'E'.
RETURN-MESSAGE = 'Goods Issue Failed!'.
EXIT. "EXIT THE RFC
ELSE.
COMMIT WORK AND WAIT.
ENDIF. |