SAP 參照sto訂單建立外向交貨BAPI
DATA: SHIP_POINT TYPE TVST-VSTEL, "裝運點/接收點
NUM_DELIVERIES TYPE VBNUM,
STOCK_TRANS_ITEMS LIKE BAPIDLVREFTOSTO OCCURS 0 WITH HEADER LINE,
DELIVERIES TYPE STANDARD TABLE OF BAPISHPDELIVNUMB,
EXTENSION_OUT TYPE STANDARD TABLE OF BAPIPAREX,
CREATED_ITEMS LIKE BAPIDLVITEMCREATED OCCURS 0 WITH HEADER LINE ,
SERIAL_NUMBERS LIKE BAPIDLVSERIALNUMBER OCCURS 0 WITH HEADER LINE ,
RETURN TYPE STANDARD TABLE OF BAPIRET2,
LF_VBELN TYPE VBELN_VL.
SHIP_POINT = '1000'. "裝運點
STOCK_TRANS_ITEMS-REF_DOC = '4500048888'. "參考憑證
STOCK_TRANS_ITEMS-REF_ITEM = '000010'.
STOCK_TRANS_ITEMS-DLV_QTY = 10.
STOCK_TRANS_ITEMS-SALES_UNIT = 'PCS'.
STOCK_TRANS_ITEMS-SALES_UNIT_ISO = 'PCS'.
APPEND STOCK_TRANS_ITEMS.
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_STO'
EXPORTING
SHIP_POINT = SHIP_POINT
* DUE_DATE =
* DEBUG_FLG =
* NO_DEQUEUE = ' '
IMPORTING
DELIVERY = LF_VBELN
NUM_DELIVERIES = NUM_DELIVERIES
TABLES
STOCK_TRANS_ITEMS = STOCK_TRANS_ITEMS
SERIAL_NUMBERS = SERIAL_NUMBERS
DELIVERIES = DELIVERIES
CREATED_ITEMS = CREATED_ITEMS
EXTENSION_OUT = EXTENSION_OUT
RETURN = RETURN.
.
IF NOT LF_VBELN IS INITIAL.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ENDIF.