I want to update picking for a delivery order with splitting batches. The quantity is getting picked but the batches are not getting updated. Following is the code that I have been using. Can anyone please tell what am I missing here?
DATA: wa_vbkok TYPE vbkok,
it_vbpok TYPE STANDARD TABLE OF vbpok,
wa_vbpok TYPE vbpok,
it_prott TYPE STANDARD TABLE OF prott.
wa_vbkok-vbeln_vl = '80000244'. "DO
wa_vbkok-vbeln = '80000244'.
wa_vbkok-komue = 'X'. "To overwrite pick qty automatically into DO Qty
wa_vbpok-vbeln_vl = '80000244'.
wa_vbpok-posnr_vl = '000010'.
wa_vbpok-vbeln = '80000244'.
wa_vbpok-posnn = '000010'.
wa_vbpok-matnr = '11000021'.
wa_vbpok-charg = '0000389'. "1st Batch
wa_vbpok-werks = 'INDO'.
wa_vbpok-lianp = 'X'. "To change delivery QTy same as Pick Qty
wa_vbpok-pikmg = '1.620'. "Quantity in 1st Batch.
APPEND wa_vbpok TO it_vbpok.
wa_vbpok-vbeln_vl = '80000244'.
wa_vbpok-posnr_vl = '000010'.
wa_vbpok-vbeln = '80000244'.
wa_vbpok-posnn = '000010'.
wa_vbpok-matnr = '11000021'.
wa_vbpok-charg = '0000390'. "2nd Batch
wa_vbpok-werks = 'INDO'.
wa_vbpok-lianp = 'X'. "To change delivery QTy same as Pick Qty
wa_vbpok-pikmg = '1.610'. "Quantity in 2nd Batch.
APPEND wa_vbpok TO it_vbpok.
wa_vbpok-vbeln_vl = '80000244'.
wa_vbpok-posnr_vl = '000010'.
wa_vbpok-vbeln = '80000244'.
wa_vbpok-posnn = '000010'.
wa_vbpok-matnr = '11000021'.
wa_vbpok-charg = '0000392'. "3rd Batch
wa_vbpok-werks = 'INDO'.
wa_vbpok-lianp = 'X'. "To change delivery QTy same as Pick Qty
wa_vbpok-pikmg = '1.630'. "Quantity in 3rd Batch.
APPEND wa_vbpok TO it_vbpok.
CALL FUNCTION 'WS_DELIVERY_UPDATE_2'
EXPORTING
vbkok_wa = wa_vbkok
synchron = 'X'
NO_MESSAGES_UPDATE_1 = ' '
commit = 'X'
delivery = '80000244'
update_picking = 'X'
TABLES
vbpok_tab = it_vbpok
prot = it_prott
.
The DO Qty was 5.000. While picking I want it to change to 4.860, i.e, the sum all the batch quantities. But with this code, the picked qty and the Do qty are changed to the quantity of the last batch in the internal table (in this case the 3rd batch). Also none of the batches are assigned to the DO.
Could anybody point out where am I going wrong?