在以下语句取消2322工厂即可
INSERT INTO STG.SAP_MARD(MATNR, WERKS, LGORT, LABST, UMLME, INSME, EINME, SPEME, LGOBE, RETME, MEINS, KLABS, KINSM, KEINM, KSPEM) select distinct TRIM(mard.MATNR) AS MATNR, TRIM(mard.WERKS) AS WERKS, TRIM(mard.LGORT) AS LGORT, mard.LABST, mard.UMLME, mard.INSME, mard.EINME, mard.SPEME, UNISTR(ASCIISTR(t001l.LGOBE)) LGOBE, mard.RETME, MARA.MEINS, mard.KLABS, mard.KINSM, mard.KEINM, mard.KSPEM from SAPSR3.mard@SAP_SEP mard JOIN SAPSR3.MARA@SAP_SEP MARA ON MARD.MANDT = MARA.MANDT AND MARD.MATNR = MARA.MATNR left join SAPSR3.t001l@SAP_SEP t001l on mard.mandt = t001l.mandt and mard.werks = t001l.werks and mard.lgort = t001l.lgort where --mard.werks in ('2061') --mard.werks in ('2211') mard.werks in (SELECT WERKS FROM SAPSR3.ZFM_FP_WERKS@SAP_SEP SZ WHERE SZ.ID IN (3)) and mard.mandt = '800' and mard.labst+mard.KLABS+mard.insme+mard.speme>0 and trim(mard.lgort) not in ('2120','2121','2220','2321','2320','2314','2510') --ADD BY ZHANGGUIPENG ON 20170712 材料入库质检工单参与FP计算 UNION ALL select distinct TRIM(mard.MATNR) AS MATNR, TRIM(mard.WERKS) AS WERKS, TRIM(mard.LGORT) AS LGORT, mard.LABST, mard.UMLME, mard.INSME, mard.EINME, mard.SPEME, UNISTR(ASCIISTR(t001l.LGOBE)) LGOBE, mard.RETME, MARA.MEINS, mard.KLABS, mard.KINSM, mard.KEINM, mard.KSPEM from SAPSR3.ztmard@SAP_SEP mard JOIN SAPSR3.MARA@SAP_SEP MARA ON MARD.MANDT = MARA.MANDT AND MARD.MATNR = MARA.MATNR left join SAPSR3.t001l@SAP_SEP t001l on mard.mandt = t001l.mandt and mard.werks = t001l.werks and mard.lgort = t001l.lgort where mard.werks in (SELECT WERKS FROM SAPSR3.ZFM_FP_WERKS@SAP_SEP SZ WHERE SZ.ID IN (3)) and mard.mandt = '800' and mard.labst+mard.KLABS+mard.insme+mard.speme>0 and trim(mard.lgort) not in ('2120','2121','2220','2321','2320','2314','2510')