优化小数组件没有回写出来,

原因是,LOC_ID加工的数据出现错误,不是工厂数据,而是6900之类

SELECT MO.PRODUCTIONORDID MO_ID,
                       IT.ITEM,
                       IT.BOM_ID,
                         IT.QTYALLOCATED
                       * FP_GET_CONVRATE (TM.ITEM_ID,
                                          TM.UDF_MEINS,
                                          NVL (TU.QTY_UOM, TM.UDF_MEINS))
                          QTYALLOCATED,
                       SUBSTR (
                          CASE
                             WHEN MO.LOC_ID = '2021' THEN  NVL (TU.LOC_ID, IIS.LOC_ID)
                             WHEN    TRIM (IIS.PROC_TYPE) || TRIM (IIS.SP_PROC_TYPE) IN ('E71') THEN '2029'
                             ELSE
                                NVL (
                                   IT.LOCATION_ID,
                                   (SELECT X.LOC_ID
                                      FROM IN_ITEM_SITE X
                                     WHERE     X.ITEM_ID = IT.ITEM
                                           AND X.SITE_ID =
                                                  CASE
                                                     WHEN    TRIM (
                                                                IIS.PROC_TYPE)
                                                          || TRIM (
                                                                IIS.SP_PROC_TYPE) =
                                                             'E70'
                                                     THEN
                                                        '2023'
                                                     ELSE
                                                        MO.LOC_ID
                                                  END
                                           AND ROWNUM = 1))
                          END,
                          1,
                          4)
                          LOC_ID,
                       NVL (TU.QTY_UOM, TM.UDF_MEINS) QTYUOM
                       ,IT.LOCATION_ID
                       ,CASE WHEN LENGTH(IT.LOCATION_ID)=9 OR LENGTH(IT.LOCATION_ID)=7 THEN IT.LOCATION_ID  
                            ELSE SUBSTR(IT.LOCATION_ID,LENGTH(IT.LOCATION_ID)-8,4)
                            END  KKA
                      , NVL (
                                   (CASE WHEN LENGTH(IT.LOCATION_ID)=9 OR LENGTH(IT.LOCATION_ID)=7 THEN IT.LOCATION_ID  
                                    ELSE SUBSTR(IT.LOCATION_ID,LENGTH(IT.LOCATION_ID)-8,4)
                                    END ) ,
                                    
                                   (SELECT X.LOC_ID
                                      FROM IN_ITEM_SITE X
                                     WHERE     X.ITEM_ID = IT.ITEM
                                           AND X.SITE_ID =
                                                  CASE
                                                     WHEN    TRIM (
                                                                IIS.PROC_TYPE)
                                                          || TRIM (
                                                                IIS.SP_PROC_TYPE) =
                                                             'E70'
                                                     THEN
                                                        --'2012'
                                                        '2023'
                                                     ELSE
                                                        MO.LOC_ID
                                                  END
                                           AND ROWNUM = 1)) AA
                  FROM OUT_MO MO,
                       TEMP_ITEM_UOM TU,
                       IN_ITEM TM,
                       IN_ITEM_SITE IIS,
                       (  SELECT NVL (TMS.COMBINE_MO, MI.ROOTID) ROOTID,
                                 MI.PARENT_ID,
                                 MI.BOM_ID,
                                 MI.SITE_ID,
                                 MI.ITEM,
                                 MI.LOCATION_ID,
                                 SUM (
                                      MI.QTYALLOCATED
                                    * (NVL (TMS.QTYORDERED / TMS.ORIG_QTY, 1)))
                                    QTYALLOCATED
                            FROM TEMP_MO_SPLIT TMS, TEMP_MO_ITEM MI
                           WHERE TMS.MO_ID(+) = MI.ROOTID
                        GROUP BY NVL (TMS.COMBINE_MO, MI.ROOTID),
                                 MI.PARENT_ID,
                                 MI.BOM_ID,
                                 MI.SITE_ID,
                                 MI.ITEM,
                                 MI.LOCATION_ID) IT
                 WHERE     MO.PRODUCTIONORDID = IT.ROOTID
                       AND IT.SITE_ID = TU.SITE_ID(+)
                       AND IT.PARENT_ID = TU.PARENT_ID(+)
                       AND IT.ITEM = TU.ITEM_ID(+)
                       AND IT.ITEM = TM.ITEM_ID
                       AND MO.LOC_ID = IIS.SITE_ID
                       AND TM.ITEM_ID = IIS.ITEM_ID
                       AND MO.PRODUCTIONORDID='5000179906/480_1-MFG0001'
                      -- AND IT.ITEM='000000102001002018'
                       and IT.LOCATION_ID is not null
                      -- and IT.LOCATION_ID not like '20%'
View Code
原文地址:https://www.cnblogs.com/Snowfun/p/9381678.html