Hi all,
I have created few sales orders and I am trying to create deliveries programatically using the BAPI BAPI_OUTB_DELIVERY_CREATE_SLS. The problem is that sometimes, when I try to create deliveries (say 10 at a time), few sales orders are mapped to a single delivery. It happens only sometimes. I have tried with the same material, same ship-to-party, same quantity. But the problems doesn't occur all the time.
Also, I have done BAPI_TRANSACTION_COMMIT and a 3 second wait after the commit for writing the data to the database.
Could anyone tell me, what is the actual problem?
CLEAR: wsale,
gd_nodeliv.
LOOP AT tsale INTO wsale WHERE check EQ 'X'.
CLEAR gw_salesorder.
gw_salesorder-ref_doc = wsale-vbeln.
APPEND gw_salesorder TO gt_salesorder.
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_SLS'
* EXPORTING
* SHIP_POINT =
* DUE_DATE =
* DEBUG_FLG =
* NO_DEQUEUE = ' '
IMPORTING
delivery = gd_vbeln
* NUM_DELIVERIES =
TABLES
sales_order_items = gt_salesorder
* SERIAL_NUMBERS =
* EXTENSION_IN =
* DELIVERIES =
* CREATED_ITEMS =
* EXTENSION_OUT =
* RETURN =
.
IF gd_vbeln IS NOT INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
IF sy-subrc EQ 0.
gd_nodeliv = gd_nodeliv + 1.
WAIT UP TO 3 SECONDS.
ENDIF.
ENDIF.
ENDLOOP.
IF gd_nodeliv EQ 0.
MESSAGE 'No deliveries created' TYPE 'S'.
ENDIF.