DATA:LT_LIPS TYPE TABLE OF LIPS. DATA:LS_LIPS TYPE LIPS. DATA:LT_VBPOK_TAB TYPE TABLE OF VBPOK. DATA:LS_VBPOK_TAB TYPE VBPOK. DATA:LT_ITEM_DATA_SPL TYPE TABLE OF /SPE/BAPIOBDLVITEMCHG. DATA:LS_ITEM_DATA_SPL TYPE /SPE/BAPIOBDLVITEMCHG. DATA:LS_HEADER_DATA TYPE BAPIOBDLVHDRCHG. DATA:LV_DELIVERY TYPE BAPIOBDLVHDRCHG-DELIV_NUMB. DATA:LS_TECHN_CONTROL TYPE BAPIDLVCONTROL. DATA:LS_HEADER_CONTROL TYPE BAPIOBDLVHDRCTRLCHG. DATA:LS_VBKOK TYPE VBKOK. DATA:LT_PROT TYPE TABLE OF PROTT. DATA:LV_ERROR(1). DATA:LV_MESSAGE TYPE STRING. SELECT * INTO CORRESPONDING FIELDS OF TABLE LT_LIPS FROM LIPS WHERE VBELN EQ PV_VBELN. CLEAR:LS_LIPS. LOOP AT LT_LIPS ASSIGNING FIELD-SYMBOL(<FS_LIPS>). CLEAR:LS_VBPOK_TAB. LS_VBPOK_TAB-VBELN_VL = <FS_LIPS>-VBELN. "交货. LS_VBPOK_TAB-POSNR_VL = <FS_LIPS>-POSNR."原行项目 LS_VBPOK_TAB-VBELN = <FS_LIPS>-VBELN. "交货. LS_VBPOK_TAB-POSNN = <FS_LIPS>-POSNR."交货项目 LS_VBPOK_TAB-MATNR = <FS_LIPS>-MATNR."物料编号 LS_VBPOK_TAB-CHARG = <FS_LIPS>-CHARG."批号 LS_VBPOK_TAB-LFIMG = <FS_LIPS>-LFIMG. LS_VBPOK_TAB-MEINS = <FS_LIPS>-MEINS. LS_VBPOK_TAB-WERKS = <FS_LIPS>-WERKS ."库存地点 LS_VBPOK_TAB-LGORT = 9000 . "库存地点 LS_VBPOK_TAB-KZLGO = ‘X‘. "库存地点可修改 LS_VBPOK_TAB-PIKMG = <FS_LIPS>-LFIMG."捡配数量 LS_VBPOK_TAB-LGMNG = <FS_LIPS>-LFIMG."交货量 APPEND LS_VBPOK_TAB TO LT_VBPOK_TAB. CLEAR:LS_ITEM_DATA_SPL. LS_ITEM_DATA_SPL-DELIV_NUMB = <FS_LIPS>-VBELN."交货 LS_ITEM_DATA_SPL-DELIV_ITEM = <FS_LIPS>-POSNR."原行项目 LS_ITEM_DATA_SPL-STGE_LOC = 9000. "库存地点 APPEND LS_ITEM_DATA_SPL TO LT_ITEM_DATA_SPL. ENDLOOP. LS_HEADER_DATA-DELIV_NUMB = PV_VBELN."交货 LS_TECHN_CONTROL-UPD_IND = ‘U‘. LS_HEADER_CONTROL-DELIV_NUMB = PV_VBELN."交货 LV_DELIVERY = PV_VBELN."交货 LS_VBKOK-VBELN_VL = PV_VBELN. LS_VBKOK-WABUC = ‘X‘. LS_VBKOK-WADAT_IST = SY-DATUM. CALL FUNCTION ‘WS_DELIVERY_UPDATE‘ EXPORTING VBKOK_WA = LS_VBKOK DELIVERY = LV_DELIVERY UPDATE_PICKING = ‘X‘ IMPORTING EF_ERROR_IN_GOODS_ISSUE_0 = LV_ERROR TABLES PROT = LT_PROT VBPOK_TAB = LT_VBPOK_TAB EXCEPTIONS ERROR_MESSAGE = 1 OTHERS = 2. IF LV_ERROR = ‘‘. READ TABLE LT_PROT TRANSPORTING NO FIELDS WITH KEY MSGTY = ‘E‘. IF SY-SUBRC = 0. LV_ERROR = ‘X‘. ENDIF. ENDIF. IF LV_ERROR IS NOT INITIAL. "创建失败 CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK‘. LOOP AT LT_PROT INTO DATA(LS_PROT) WHERE MSGTY = ‘E‘. CLEAR:LV_MESSAGE. MESSAGE ID LS_PROT-MSGID TYPE LS_PROT-MSGTY NUMBER LS_PROT-MSGNO WITH LS_PROT-MSGV1 LS_PROT-MSGV2 LS_PROT-MSGV3 LS_PROT-MSGV4 INTO LV_MESSAGE. CONCATENATE O_RETURN-MESSAGE LV_MESSAGE INTO O_RETURN-MESSAGE SEPARATED BY ‘/‘. ENDLOOP. O_RETURN-TYPE = ‘E‘. ELSE. "创建成功 CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT‘ EXPORTING WAIT = ‘X‘. SELECT SINGLE MBLNR INTO O_RETURN-ZDJH FROM MSEG WHERE VBELN_IM = LV_DELIVERY. O_RETURN-TYPE = ‘S‘. ENDIF.
原文地址:https://www.cnblogs.com/rainysblog/p/10923332.html
时间: 2024-10-22 08:44:12