建立帶有訂單參考的外向交貨:BAPI…
阿新 • • 發佈:2019-01-31
PARAMETERS P_SOD TYPE CHAR10.
*---Bapi Data Define
DATA:DELIVERY TYPE BAPISHPDELIVNUMB-DELIV_NUMB,
NUM_DELIVERIES TYPE BAPIDLVCREATEHEADER-NUM_DELIVERIES,
SALES_ORDER_ITEMS LIKE BAPIDLVREFTOSALESORDER OCCURS 0 WITH HEADER LINE,
RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE .
START-OF-SELECTION.
*---Assign Value
SALES_ORDER_ITEMS-REF_DOC = P_SOD. "參考訂單號
SALES_ORDER_ITEMS-REF_ITEM = '000010'. "行專案號
SALES_ORDER_ITEMS-DLV_QTY = 18"數量
SALES_ORDER_ITEMS-SALES_UNIT = 'TO'. "單位
APPEND SALES_ORDER_ITEMS.
*---Call BAPI Function
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_SLS'
IMPORTING
DELIVERY = DELIVERY
NUM_DELIVERIES = NUM_DELIVERIES
TABLES
SALES_ORDER_ITEMS = SALES_ORDER_ITEMS
RETURN = RETURN.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
*---Bapi Data Define
DATA:DELIVERY TYPE BAPISHPDELIVNUMB-DELIV_NUMB,
NUM_DELIVERIES TYPE BAPIDLVCREATEHEADER-NUM_DELIVERIES,
SALES_ORDER_ITEMS LIKE BAPIDLVREFTOSALESORDER OCCURS 0 WITH HEADER LINE,
RETURN
START-OF-SELECTION.
*---Assign Value
SALES_ORDER_ITEMS-REF_DOC = P_SOD. "參考訂單號
SALES_ORDER_ITEMS-REF_ITEM = '000010'. "行專案號
SALES_ORDER_ITEMS-DLV_QTY = 18"數量
SALES_ORDER_ITEMS-SALES_UNIT = 'TO'.
APPEND SALES_ORDER_ITEMS.
*---Call BAPI Function
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CREATE_SLS'
IMPORTING
DELIVERY = DELIVERY
NUM_DELIVERIES = NUM_DELIVERIES
TABLES
SALES_ORDER_ITEMS = SALES_ORDER_ITEMS
RETURN = RETURN.
CALL FUNCTION
EXPORTING
WAIT = 'X'.