Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Outbound Delivery Update ( Quantity )

Former Member
0 Kudos
1,427

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.


6 REPLIES 6

hemanth_kumar21
Contributor
0 Kudos
319

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).

0 Kudos
319

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,

 


0 Kudos
319

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

0 Kudos
319

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:

DeliveryItemMaterialDlv. Qty
800000202210CC2XT020100
800000202220BAHA0140160
8000002022900001BAHA01401610
8000002022900002CC2XT0201010

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.

0 Kudos
319

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?

0 Kudos
319

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.