REPORT Z_UPDATE_DELIVERY.
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.
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.
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 = 1.
ITEM_DATA-DLV_QTY_IMUNIT = 1.
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.
CLEAR 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.
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 = ' '.
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
阅读(13582) | 评论(0) | 转发(0) |