TABLES LIKP.
PARAMETERS P_DEL LIKE LIKP-VBELN DEFAULT '8000002260'.
DATA:STR_HEADER_DATA LIKE BAPIOBDLVHDRCHG,
STR_HEADER_CONTROL LIKE BAPIOBDLVHDRCTRLCHG.
DATA IT_RETURN TYPE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE.
DATA IT_HEADER_DEADLINES TYPE STANDARD TABLE OF BAPIDLVDEADLN WITH HEADER LINE.
DATA :ITEM_DATA LIKE BAPIOBDLVITEMCHG OCCURS 0 WITH HEADER LINE,
ITEM_CONTROL LIKE BAPIOBDLVITEMCTRLCHG OCCURS 0 WITH HEADER LINE,
WA_LIPS LIKE LIPS OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
"修改外向交货单
PERFORM MODIFY1.
"更改拣配数量
PERFORM MODIFY2 .
*&---------------------------------------------------------------------*
*& Form MODIFY1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM MODIFY1 .
DATA: V_16(16) TYPE C.
DATA V_DEL LIKE BAPIOBDLVHDRCHG-DELIV_NUMB.
SELECT SINGLE * FROM LIKP WHERE VBELN = P_DEL.
CONCATENATE SY-DATUM SY-UZEIT INTO V_16.
STR_HEADER_DATA-UNLOAD_PT = LIKP-ABLAD. "卸货点
STR_HEADER_DATA-UNIT_OF_WT = LIKP-GEWEI. "重量单位
STR_HEADER_DATA-INCOTERMS1 = LIKP-INCO1. "国际贸易条款 (部分1)
STR_HEADER_DATA-INCOTERMS2 = LIKP-INCO2. "国际贸易条款 (部分2)
STR_HEADER_DATA-DOOR = LIKP-LGTOR. "仓库门号码
STR_HEADER_DATA-DLV_BLOCK = LIKP-LIFSK. "交货冻结(抬头)
STR_HEADER_DATA-DLV_PRIO = LIKP-LPRIO. "交货优先权
STR_HEADER_DATA-NET_WEIGHT = LIKP-NTGEW. "净重量
STR_HEADER_DATA-ROUTE = LIKP-ROUTE. "路线
STR_HEADER_DATA-DELIV_NUMB = LIKP-VBELN. "交货
STR_HEADER_DATA-VOLUMEUNIT = LIKP-VOLEH. "体积单位
STR_HEADER_DATA-VOLUME = LIKP-VOLUM. "业务量
STR_HEADER_DATA-SHIP_COND = LIKP-VSBED. "装运条件
V_DEL = LIKP-VBELN.
STR_HEADER_DATA-DELIV_NUMB = LIKP-VBELN.
STR_HEADER_CONTROL-GDSI_DATE_FLG = 'X'. "确认交货日期
IT_HEADER_DEADLINES-TIMETYPE = 'WSHDRWADTI'.
IT_HEADER_DEADLINES-TIMESTAMP_UTC = V_16. "拼接而成 CONCATENATE SY-DATUM SY-UZEIT INTO V_16.
APPEND IT_HEADER_DEADLINES.
SELECT * INTO WA_LIPS FROM LIPS WHERE VBELN = P_DEL.
ITEM_DATA-DELIV_NUMB = WA_LIPS-VBELN.
ITEM_DATA-DELIV_ITEM = WA_LIPS-POSNR.
ITEM_DATA-MATERIAL = WA_LIPS-MATNR.
ITEM_DATA-BATCH = WA_LIPS-CHARG. "批号
ITEM_DATA-DLV_QTY = 2. "实际已交货量(按销售单位)
ITEM_DATA-DLV_QTY_IMUNIT = 2. "以仓库保管单位级的实际交货数量
ITEM_DATA-FACT_UNIT_NOM = WA_LIPS-UMVKZ. "销售数量转换成SKU的分子(因子)
ITEM_DATA-FACT_UNIT_DENOM = WA_LIPS-UMVKN. "销售数量转换为 SKU 的值(除数)
ITEM_DATA-CONV_FACT = WA_LIPS-UMREF. "转换因子: 数量
ITEM_DATA-GROSS_WT = WA_LIPS-BRGEW. "毛重
ITEM_DATA-NET_WEIGH T = WA_LIPS-NTGEW. "净重量
ITEM_DATA-UNIT_OF_WT = WA_LIPS-GEWEI. "重量单位
ITEM_DATA-VOLUMEUNIT = WA_LIPS-VOLEH. "体积单
ITEM_DATA-SALES_UNIT = WA_LIPS-VRKME. "销售单位
ITEM_DATA-BASE_UOM = WA_LIPS-MEINS. "基本计量单位
ITEM_DATA-STOCK_TYPE = WA_LIPS-INSMK. "库存类型
ITEM_DATA-VAL_TYPE = WA_LIPS-BWTAR. "评估类型
ITEM_DATA-INSPLOT = WA_LIPS-QPLOS. "检验批编号
ITEM_DATA-VOLUME = WA_LIPS-VOLUM. "业务量
APPEND ITEM_DATA.
CLEAR ITEM_DATA.
"*CHG_DELQTY " 修改交货数量
"*DEL_ITEM " 标志:删除交货项
"*VOLUME_FLG " 量的确认
"*NET_WT_FLG " 净重的确认
"*GROSS_WT_FLG " 毛重的确认
ITEM_CONTROL-DELIV_NUMB = WA_LIPS-VBELN.
ITEM_CONTROL-DELIV_ITEM = WA_LIPS-POSNR.
ITEM_CONTROL-CHG_DELQTY = 'X'. "修改交货数量
APPEND ITEM_CONTROL.
ENDSELECT.
CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
EXPORTING
HEADER_DATA = STR_HEADER_DATA
HEADER_CONTROL = STR_HEADER_CONTROL
DELIVERY = V_DEL
TABLES
HEADER_DEADLINES = IT_HEADER_DEADLINES
ITEM_DATA = ITEM_DATA
ITEM_CONTROL = ITEM_CONTROL
RETURN = IT_RETURN.
IF IT_RETURN[] IS INITIAL.
COMMIT WORK.
ELSE.
LOOP AT IT_RETURN.
MESSAGE ID IT_RETURN-ID TYPE IT_RETURN-TYPE NUMBER IT_RETURN-NUMBER.
ENDLOOP.
ENDIF.
ENDFORM. " MODIFY1
*&---------------------------------------------------------------------*
*& Form MODIFY2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM MODIFY2 .
*& 更改拣配数量
DATA:VBKOK_WA TYPE VBKOK,
VBPOK_TAB TYPE VBPOK OCCURS 0 WITH HEADER LINE,
XLIPS TYPE LIPS OCCURS 0 WITH HEADER LINE .
CLEAR: VBKOK_WA, VBPOK_TAB, XLIPS.
REFRESH: VBPOK_TAB, XLIPS.
VBKOK_WA-VBELN_VL = P_DEL.
SELECT * FROM LIPS INTO TABLE XLIPS
WHERE VBELN = VBKOK_WA-VBELN_VL.
LOOP AT XLIPS.
CLEAR: VBPOK_TAB.
VBPOK_TAB-VBELN_VL = XLIPS-VBELN.
VBPOK_TAB-POSNR_VL = XLIPS-POSNR.
VBPOK_TAB-VBELN = XLIPS-VBELN.
VBPOK_TAB-POSNN = XLIPS-POSNR.
VBPOK_TAB-PIKMG = XLIPS-LFIMG. "实际已交货量(按销售单位)
VBPOK_TAB-MEINS = XLIPS-MEINS. "基本计量单位
VBPOK_TAB-NDIFM = 0. "按库存计量单位的目的地差异数量
VBPOK_TAB-TAQUI = ' '. "ID:MM-WM传递定单确定
VBPOK_TAB-CHARG = XLIPS-CHARG. "批次
VBPOK_TAB-MATNR = XLIPS-MATNR. "物料
VBPOK_TAB-ORPOS = 0.
APPEND VBPOK_TAB.
ENDLOOP.
CALL FUNCTION 'SD_DELIVERY_UPDATE_PICKING'
EXPORTING
VBKOK_WA = VBKOK_WA
SYNCHRON = 'X'
TABLES
VBPOK_TAB = VBPOK_TAB.
COMMIT WORK AND WAIT.
ENDFORM. " MODIFY2