参考代码转自:http://blog.sina.com.cn/s/blog_4c66402b01012lgr.html
感谢。
测试一把,再做总结。
1.更改外向交货单;
2.更改内向交货单。
http://blog.sina.com.cn/s/blog_4c66402b01012lgr.html REPORT Y_CHANGE_ODN. TABLES LIKP. PARAMETERS P_DEL LIKE LIKP-VBELN DEFAULT ''. 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. 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-GROSS_WT *UNIT_OF_WT_ISO *VOLUMEUNIT_ISO STR_HEADER_DATA-UNLOAD_PT = LIKP-ABLAD. STR_HEADER_DATA-UNIT_OF_WT = LIKP-GEWEI. STR_HEADER_DATA-INCOTERMS1 = LIKP-INCO1. STR_HEADER_DATA-INCOTERMS2 = LIKP-INCO2. 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. 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. ITEM_DATA-FACT_UNIT_DENOM = WA_LIPS-UMVKN. ITEM_DATA-CONV_FACT = WA_LIPS-UMREF. ITEM_DATA-GROSS_WT = WA_LIPS-BRGEW. ITEM_DATA-NET_WEIGHT = 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. 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. COMMIT WORK. *& 更改拣配数量 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-vbtyp_n = 'Q'. VBPOK_TAB-PIKMG = XLIPS-LFIMG. VBPOK_TAB-MEINS = XLIPS-MEINS. VBPOK_TAB-NDIFM = 0. VBPOK_TAB-TAQUI = ' '. 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' * NO_MESSAGES_UPDATE = ' ' * NICHT_SPERREN = ' ' * AUFRUFER_T = ' ' * IF_ERROR_MESSAGES_SEND = 'X' TABLES VBPOK_TAB = VBPOK_TAB. COMMIT WORK AND WAIT.