2013 Oct 22 9:26 AM
Hi experts,
I wanna update values of fields below by using standard SAP bapi.
+Delivery Quantity
+Cumulative Batch Quantity.
I am using BAPI_OUTB_DELIVERY_CHANGE but it's not affect on both database LIPS and transaction VL03N.
Please share me solution to pass it.
My simple code:
TABLES: lips.
DATA: LWA_HEADER_DATA LIKE BAPIOBDLVHDRCHG,
LWA_HEADER_CONTROL LIKE BAPIOBDLVHDRCTRLCHG,
GWA_SD_DOCUMENT TYPE lips,
LT_ITEM_DATA LIKE TABLE OF BAPIOBDLVITEMCHG,
LWA_ITEM_DATA LIKE LINE OF LT_ITEM_DATA,
LV_OLD_DELIV LIKE GWA_SD_DOCUMENT-VBELN,
LV_NEW_DELIV LIKE GWA_SD_DOCUMENT-VBELN,
LV_OLD_MATNR LIKE GWA_SD_DOCUMENT-MATNR,
LV_NEW_MATNR LIKE GWA_SD_DOCUMENT-MATNR,
LWA_TECHN LIKE BAPIDLVCONTROL,
LT_ITEM_CONTROL LIKE TABLE OF BAPIOBDLVITEMCTRLCHG,
LWA_ITEM_CONTROL LIKE LINE OF LT_ITEM_CONTROL,
LT_RETURN LIKE TABLE OF BAPIRET2.
LWA_TECHN-UPD_IND = 'U'.
LWA_ITEM_DATA-DELIV_NUMB = '80003372'.
LWA_ITEM_DATA-DELIV_ITEM = '10'.
LWA_ITEM_DATA-MATERIAL = 'L-40F'.
LWA_ITEM_DATA-DLV_QTY = '5'.
LWA_ITEM_DATA-DLV_QTY_IMUNIT = '5'.
LWA_ITEM_DATA-SALES_UNIT = 'BIC'.
LWA_ITEM_DATA-BASE_UOM = 'BIC'.
LWA_ITEM_DATA-FACT_UNIT_NOM = 1.
LWA_ITEM_DATA-FACT_UNIT_DENOM = 1.
APPEND LWA_ITEM_DATA TO LT_ITEM_DATA.
LWA_ITEM_CONTROL-DELIV_NUMB = '80003372'.
LWA_ITEM_CONTROL-DELIV_ITEM = '10'.
LWA_ITEM_CONTROL-CHG_DELQTY = 'X'.
APPEND LWA_ITEM_CONTROL TO LT_ITEM_CONTROL.
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
EXPORTING
HEADER_DATA = LWA_HEADER_DATA
HEADER_CONTROL = LWA_HEADER_CONTROL
DELIVERY = '80003372'
TABLES
ITEM_DATA = LT_ITEM_DATA
ITEM_CONTROL = LT_ITEM_CONTROL
RETURN = LT_RETURN.
2013 Oct 22 9:36 AM
Hi Pham Nghia,.
Please use 'BAPI_TRANSACTION_COMMIT' after the 'BAPI_OUTB_DELIVERY_CHANGE' call.
After using 'BAPI_TRANSACTION_COMMIT' it is not affect in database tables or transaction level.
please check your internal table LT_RETURN in debug mode (alway sy-subrc is 0 for BAPI's).
2013 Oct 22 1:08 PM
Hi Modadugu Hemanth Kumar,
My table LT_RETURN
MSGID : VL
MSGNR : 602
So I got message 'Good Issue has already been posted for delivery' for responsible MSGID and MSGNR
Before above code
I'm adding function BAPI_TRANSACTION_COMMIT and execute it. But.
Terminally, I've still not affect on both database LIPS and transaction VL03N yet.
Any possible solutions for me.
Thanks,
2013 Oct 22 2:49 PM
Hi Pham,
You described the message as below
So I got message 'Good Issue has already been posted for delivery' for responsible MSGID and MSGNR
You cannot change a delivery for which PGI is already done. You can only change open deliveries.
Regards,
Ankur Parab
2013 Oct 23 5:49 AM
Hi Ankur,
I followed your suggestion. I updated an other outbound delivery. Which's goods issue is A (Not yet started). I have not updated he OD yet. And I got message 'Material is not the same for confirmation and delivery".
My OD data:
Delivery | Item | Material | Dlv. Qty |
8000002022 | 10 | CC2XT02010 | 0 |
8000002022 | 20 | BAHA014016 | 0 |
8000002022 | 900001 | BAHA014016 | 10 |
8000002022 | 900002 | CC2XT02010 | 10 |
My simple code:
DATA : I_HEADER_DATA LIKE BAPIOBDLVHDRCHG. "Delivery header
DATA : I_HEADER_CONTROL LIKE BAPIOBDLVHDRCTRLCHG. "delivery header
*control
DATA : I_DELIVERY_NO LIKE BAPIOBDLVHDRCHG-DELIV_NUMB. "deliver number
DATA : I_TECHN_CONTROL LIKE BAPIDLVCONTROL. "TECHN_CONTROL
DATA : I_ITEM_DATA LIKE BAPIOBDLVITEMCHG OCCURS 0 WITH HEADER LINE.
"ITEM_DATA delivery item
DATA : I_ITEM_CONTROL LIKE BAPIOBDLVITEMCTRLCHG OCCURS 0 WITH HEADER
LINE. "ITEM_CONTROL
DATA : I_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE. "Return
*Set Delivery Header data
I_DELIVERY_NO = '8000002022'.
I_HEADER_DATA-DELIV_NUMB = I_DELIVERY_NO.
I_TECHN_CONTROL-UPD_IND = 'U'.
I_HEADER_CONTROL-DELIV_NUMB = I_DELIVERY_NO.
*Create Delivery item by WMS return batch split
*First item from delivery item
I_ITEM_DATA-DELIV_NUMB = I_DELIVERY_NO.
I_ITEM_DATA-DELIV_ITEM = '10'.
I_ITEM_DATA-MATERIAL = 'CC2XT02010'.
*I_ITEM_DATA-dlv_qty = 0.
*I_ITEM_DATA-GROSS_WT = 10.
I_ITEM_DATA-FACT_UNIT_NOM = 1.
I_ITEM_DATA-fact_unit_denom = 1.
append I_ITEM_DATA.
clear I_ITEM_DATA.
*Create Delivery item by WMS return batch split
*First item from delivery item
I_ITEM_DATA-DELIV_NUMB = I_DELIVERY_NO.
I_ITEM_DATA-DELIV_ITEM = '20'.
I_ITEM_DATA-MATERIAL = 'BAHA014016'.
*I_ITEM_DATA-DLV_QTY = 9.
*I_ITEM_DATA-GROSS_WT = 10.
I_ITEM_DATA-FACT_UNIT_NOM = 1.
I_ITEM_DATA-FACT_UNIT_DENOM = 1.
append I_ITEM_DATA.
clear I_ITEM_DATA.
I_ITEM_DATA-DELIV_NUMB = I_DELIVERY_NO.
I_ITEM_DATA-DELIV_ITEM = '900001'.
I_ITEM_DATA-HIERARITEM = '10'. "The batch split record
I_ITEM_DATA-USEHIERITM = '1'.
I_ITEM_DATA-MATERIAL = 'BAHA014016'.
I_ITEM_DATA-DLV_QTY = 9.
I_ITEM_DATA-DLV_QTY_IMUNIT = 9.
I_ITEM_DATA-FACT_UNIT_NOM = 1.
I_ITEM_DATA-FACT_UNIT_DENOM = 1.
append I_ITEM_DATA.
clear I_ITEM_DATA.
*
I_ITEM_DATA-DELIV_NUMB = I_DELIVERY_NO.
I_ITEM_DATA-DELIV_ITEM = '900002'. "The batch split record below
*delivery item hierary
I_ITEM_DATA-HIERARITEM = '20'.
I_ITEM_DATA-USEHIERITM = '1'.
I_ITEM_DATA-MATERIAL = 'CC2XT02010'.
*I_ITEM_DATA-BATCH = 'S002'.
I_ITEM_DATA-DLV_QTY = 9.
I_ITEM_DATA-DLV_QTY_IMUNIT = 9.
I_ITEM_DATA-FACT_UNIT_NOM = 1.
I_ITEM_DATA-FACT_UNIT_DENOM = 1.
append I_ITEM_DATA.
clear I_ITEM_DATA.
I_ITEM_CONTROL-DELIV_NUMB = I_DELIVERY_NO.
I_ITEM_CONTROL-DELIV_ITEM = '10'.
I_ITEM_CONTROL-CHG_DELQTY = 'X'.
append I_ITEM_CONTROL.
clear I_ITEM_DATA.
I_ITEM_CONTROL-DELIV_NUMB = I_DELIVERY_NO.
I_ITEM_CONTROL-DELIV_ITEM = '20'.
I_ITEM_CONTROL-CHG_DELQTY = 'X'.
append I_ITEM_CONTROL.
clear I_ITEM_DATA.
I_ITEM_CONTROL-DELIV_NUMB = I_DELIVERY_NO.
I_ITEM_CONTROL-DELIV_ITEM = '900001'.
I_ITEM_CONTROL-CHG_DELQTY = 'X'.
append I_ITEM_CONTROL.
clear I_ITEM_DATA.
I_ITEM_CONTROL-DELIV_NUMB = I_DELIVERY_NO.
I_ITEM_CONTROL-DELIV_ITEM = '900002'.
I_ITEM_CONTROL-CHG_DELQTY = 'X'.
append I_ITEM_CONTROL.
clear I_ITEM_DATA.
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
EXPORTING
HEADER_DATA = I_HEADER_DATA
HEADER_CONTROL = I_HEADER_CONTROL
DELIVERY = I_DELIVERY_NO
TECHN_CONTROL = I_TECHN_CONTROL
TABLES
ITEM_DATA = I_ITEM_DATA
ITEM_CONTROL = I_ITEM_CONTROL
RETURN = I_RETURN.
IF sy-subrc EQ 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = ' '.
ENDIF.
Regards,
Nghia Pham.
2013 Oct 23 5:59 AM
There is a batch split in the delivery item. Which quantity you have to updated? does system allow you update that quantity when you do it from tcode?
2013 Oct 23 8:28 AM
Briefly I wanna use a bapi to update 'cumulative batch quantity (Cumul.qty)'.
The reason for using bapi is that, relative values of Cumul.qty, such as Gross weight, net weight and so on will be updated automatically.
Regards.
Nghia Pham.