改STO创建的DN(内向交货单,外向交货单)单项目中的库存地点,就是LIPS-LGORT。
只能是使用DN单的更新BAPI函数,在过账前进行修改一下,
REPORT ZTEST10.
TABLES: LIPS.
PARAMETERS: P_VBELN TYPE LIPS-VBELN.
DATA: LS_STR_HEADER_DATA LIKE BAPIOBDLVHDRCHG,
LT_STR_HEADER_CONTROL LIKE BAPIOBDLVHDRCTRLCHG,
LS_TECHN_CONTROL LIKE BAPIDLVCONTROL.
DATA: LT_ITEM_DATA LIKE TABLE OF BAPIOBDLVITEMCHG,
LS_ITEM_DATA LIKE BAPIOBDLVITEMCHG,
LT_ITEM_CONTROL LIKE TABLE OF BAPIOBDLVITEMCTRLCHG,
LS_ITEM_CONTROL LIKE BAPIOBDLVITEMCTRLCHG,
LT_ITEM_DATA_SPL LIKE TABLE OF /SPE/BAPIOBDLVITEMCHG,
LS_ITEM_DATA_SPL LIKE /SPE/BAPIOBDLVITEMCHG,
LT_RETURN LIKE TABLE OF BAPIRET2,
LS_RETURN LIKE BAPIRET2.
DATA: LT_LIPS LIKE TABLE OF LIPS,
LS_LIPS LIKE LIPS.
SELECT *
INTO TABLE LT_LIPS
FROM LIPS
WHERE VBELN = P_VBELN.
LS_STR_HEADER_DATA-DELIV_NUMB = P_VBELN.
LT_STR_HEADER_CONTROL-DELIV_NUMB = P_VBELN.
LS_TECHN_CONTROL-UPD_IND = 'U'.
LOOP AT LT_LIPS INTO LS_LIPS.
LS_ITEM_DATA-DELIV_NUMB = LS_LIPS-VBELN.
LS_ITEM_DATA-DELIV_ITEM = LS_LIPS-POSNR.
LS_ITEM_DATA-MATERIAL = LS_LIPS-MATNR.
LS_ITEM_DATA-BATCH = LS_LIPS-CHARG.
LS_ITEM_DATA-DLV_QTY = LS_LIPS-LFIMG.
LS_ITEM_DATA-DLV_QTY_IMUNIT = LS_LIPS-LFIMG.
LS_ITEM_DATA-HIERARITEM = LS_LIPS-POSNR.
LS_ITEM_DATA-USEHIERITM = 1.
LS_ITEM_DATA-FACT_UNIT_NOM = LS_LIPS-UMVKZ.
LS_ITEM_DATA-FACT_UNIT_DENOM = LS_LIPS-UMVKN.
LS_ITEM_DATA-BASE_UOM = LS_LIPS-MEINS.
LS_ITEM_DATA-SALES_UNIT = LS_LIPS-VRKME.
APPEND LS_ITEM_DATA TO LT_ITEM_DATA.
LS_ITEM_CONTROL-DELIV_NUMB = LS_LIPS-VBELN.
LS_ITEM_CONTROL-DELIV_ITEM = LS_LIPS-POSNR.
LS_ITEM_CONTROL-CHG_DELQTY = 'X'.
APPEND LS_ITEM_CONTROL TO LT_ITEM_CONTROL.
LS_ITEM_DATA_SPL-DELIV_NUMB = LS_LIPS-VBELN.
LS_ITEM_DATA_SPL-DELIV_ITEM = LS_LIPS-POSNR.
LS_ITEM_DATA_SPL-PICK_DENIAL = 'X'.
LS_ITEM_DATA_SPL-STGE_LOC = 'C001'. "库存地点
APPEND LS_ITEM_DATA_SPL TO LT_ITEM_DATA_SPL.
LS_ITEM_DATA_SPL-DELIV_NUMB = LS_LIPS-VBELN."交货
LS_ITEM_DATA_SPL-DELIV_ITEM = LS_LIPS-POSNR."原行项目
LS_ITEM_DATA_SPL-STGE_LOC = 'C001'. "库存地点
APPEND LS_ITEM_DATA_SPL TO LT_ITEM_DATA_SPL.
ENDLOOP.
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
EXPORTING
HEADER_DATA = LS_STR_HEADER_DATA
HEADER_CONTROL = LT_STR_HEADER_CONTROL
DELIVERY = P_VBELN
TECHN_CONTROL = LS_TECHN_CONTROL
TABLES
* HEADER_DEADLINES = IT_HEADER_DEADLINES
ITEM_DATA = LT_ITEM_DATA
LS_ITEM_CONTROL = LT_ITEM_CONTROL
ITEM_DATA_SPL = LT_ITEM_DATA_SPL
RETURN = LT_RETURN.
IF SY-SUBRC = 0.
COMMIT WORK.
ENDIF.
* IF lt_return[] IS INITIAL.
* CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* wait = 'X'.