描述:此问题一直存在,只是用户没有发现,最近提出,部分2020年交期的PR回写到SAP中
优化:
SELECT MAX (PR.ORDERID), PR.ITEM, SUBSTR (PR.RECOMMENDEDSUPID, 6), TRUNC (PR.PORELEASEDATE), SUM (PR.QTYPLANNED), IT.PROC_GROUP_ID, IT.PROC_GROUP_DESCR, IT.SITE_ID, SI.LOCATION_ID, SI.QTY_UOM, --ALTER BY HUANGYANGXIONG ON 20160509 直接取FP算出来的可用日期回写 --PR.PORELEASEDATE + NVL (SI.PROC_LEAD_TIME, 0) PLANNEDDELDATE PR.PLANNEDDELDATE FROM ABPPMGR.PROCUREMENTPLAN PR, IN_ITEM_SITE IT, IN_SUPPLIER_ITEM SI WHERE PR.ITEM = IT.ITEM_ID AND IT.SITE_ID = SUBSTR (PR.RECOMMENDEDSUPID, 1, 4) AND SI.ITEM_ID = IT.ITEM_ID AND SI.SUPPLIER_ID = PR.RECOMMENDEDSUPID AND SI.UDF_ITEM_TYPE_ID = '0' AND PR.ORDERID LIKE '%PROC%' AND SUBSTR(PR.RECOMMENDEDSUPID,INSTR(PR.RECOMMENDEDSUPID,'_')+5) IN ( SELECT DISTINCT SUPPLIER_ID FROM SAP_SUPPLIER_MINQTY) AND PR.ITEM in ('000000103001000371','000000103001000372','000000103001000373') --hide by landor on 20180313 将2020年交期的PR回写出来了 --改取值侧重的是展望期,不能用 RECOMMENDEDSUPID去关联,因为一个RECOMMENDEDSUPID去关联对应多个批准日期 /* AND EXISTS(SELECT NULL FROM ABPPMGR.PROCUREMENTPLAN AP WHERE (TRUNC (AP.PORELEASEDATE) <= sysdate + DECODE (1, 6, 1, 0) + 14) AND PR.RECOMMENDEDSUPID = AP.RECOMMENDEDSUPID) */ GROUP BY PR.ITEM, SUBSTR (PR.RECOMMENDEDSUPID, 6), TRUNC (PR.PORELEASEDATE), IT.PROC_GROUP_ID, IT.PROC_GROUP_DESCR, IT.SITE_ID, SI.LOCATION_ID, SI.QTY_UOM, --PR.PORELEASEDATE + NVL (SI.PROC_LEAD_TIME, 0); PR.PLANNEDDELDATE;
select PLANNEDDELDATE,PR.* from ABPPMGR.PROCUREMENTPLAN PR WHERE PR.ITEM in ('000000103001000371','000000103001000372','000000103001000373')