芯片172没有扣减损耗,
取数:SAP_STPO的AUSCH
IN_BOM_DETAILS:耗损比例COMPONENT_YIELD_UOM
存储过程FP_MO2SAP:supplydmdpegplan到out_mo_item里面扣减耗損邏輯
下午回写后比对
select O.PRODUCTIONORDID,O.ITEM,O.qtyper ,S.qtyallocated from out_mo_item O join ABPPMGR.supplydmdpegplan S on O.PRODUCTIONORDID=S.DEMANDORDERID and O.ITEM=S.ITEM
--回写前 图1 select demandorderid,ITEM,qtyallocated from ABPPMGR.SUPPLYDMDPEGPLAN where demandorderid like '%5000118200/660_1%' and item like '%103007000714%'; --回写到SAP 图2 select * from out_mo_item where productionordid like '%5000118200/660_1%' and item like '%103007000714%';
一、.执行FP_MO2SAP存储过程到1617行,结果如图,芯片还是以销售订单号169规划,另外一款还是以ABPPMGR数据表一样204个
二、继续
执行如下存储过程,结果就马上变成172和169
--add by *** on 20161117 处理报SHORT的异常工单组件 SAP_MO2SAP_HandleShortMo(EXITCODE);
细分存储过程SAP_MO2SAP_HandleShortMo:
1.执行如下,芯片169马上变成208.08:
--找到报SHORT的订单的原始订单需求数量,并更新工单组件的数量,以便乘以最小分配比例 MERGE INTO OUT_MO_ITEM OMI USING (--SELECT AD.PROBLEMPRODORDERID MO_ID, select * from( SELECT distinct AD.PROBLEMPRODORDERID MO_ID, --alter by ** on 20170104去除重复值 ST.COMBINE_MO, AD.PROBLEMITEM ITEM_ID, --ALTER BY ** ON 20161122 新增考虑BOM的单位用量,然后直接取IN_BOM_DETAILS的损耗比例 AD.QTYORDERED*IBD.USAGE_QTY*(1+NVL(IBD.COMPONENT_YIELD_UOM,0)) AS QTYORDERED, AD.ITEMSHORTNESS, AD.QTYORDERED*IBD.USAGE_QTY*(1+NVL(IBD.COMPONENT_YIELD_UOM,0)) - AD.ITEMSHORTNESS PEG_QTY, ROW_NUMBER () OVER ( PARTITION BY AD.PROBLEMPRODORDERID ORDER BY AD.PROBLEMPRODORDERID)rn FROM ABPPMGR.DEMANDPROBDETAILS AD JOIN STG.TEMP_MO_SPLIT ST ON AD.PROBLEMPRODORDERID = ST.MO_ID JOIN ABPPMGR.MANUFACTURINGPLN AM ON AD.PROBLEMPRODORDERID = AM.PRODUCTIONORDERID LEFT JOIN STG.IN_BOM_DETAILS IBD ON TRIM(SUBSTR(AM.BOMID,INSTR(AM.BOMID,'_')+1)) = TRIM(IBD.BOM_ID) AND AD.PROBLEMITEM = IBD.ITEM_ID WHERE AD.PROBLEMTYPE = 'SHORT' AND ST.COMBINE_MO IN (SELECT OMI.PRODUCTIONORDID FROM STG.OUT_MO_ITEM OMI) --ADD BY ** ON 20170509 DELETE THE DOUBLE DATA TEMPORARILY AND AD.PROBLEMITEM <>'000000103002000008')where rn=1) AD ON (OMI.PRODUCTIONORDID = AD.COMBINE_MO AND OMI.ITEM = AD.ITEM_ID) WHEN MATCHED THEN UPDATE SET OMI.QTYPER = AD.QTYORDERED;
2.执行如下,芯片马上为208.08变回172,而其它组件却由204变成169进行回写SAP,后者是正确的,前者有误
select * from TEMP_MO_ITEM where ROOTID like '%5000118200/660_1%' --ORDER BY QTYALLOCATED DESC and ITEM in ('000000103007000714','000000104004000069')
INSERT INTO TEMP_MO_ITEM (ROOTID, PARENT_ID, ITEM, BOM_ID, QTYALLOCATED, LOCATION_ID, SITE_ID) SELECT TMP.MO_ID ROOTID, TMP.ITEM PARENT_ID, SD.ITEM, MP.BOMID BOM_ID, SUM (SD.QTYALLOCATED) QTYALLOCATED, MIN ( DECODE (SD.LOCATIONID, '{unspecified}', NULL, SD.LOCATIONID)) LOCATION_ID, TMP.LOC_ID FROM TEMP_SDPP SD, TEMP_MO TMP, ABPPMGR.MANUFACTURINGPLN MP WHERE TMP.MO_ID = SD.ROOTID AND MP.PRODUCTIONORDERID = SD.DEMANDORDERID GROUP BY TMP.MO_ID, SD.ITEM, TMP.ITEM, MP.BOMID, TMP.LOC_ID;
select * from TEMP_SDPP where --item in ('000000103007000714','000000102002000742')and DEMANDORDERID like '%5000118200/660_1%' order by qtyallocated desc
SELECT DEMANDORDERID, DEMANDLINEID, DEMANDTYPE, SD.ITEM, QTYALLOCATED, LOCATIONID, SUPPLYLINEID, SUPPLYORDERID, SUPPLYTYPE, QTYUOM, CASE WHEN SUPPLYTYPE IN ('OH', 'PO', 'PROC') THEN 0 ELSE (SELECT COUNT (*) FROM DUAL WHERE EXISTS (SELECT NULL FROM IN_BOM_DETAILS DT WHERE DT.ITEM_ID = SD.ITEM AND DT.IS_PHANTOM = '1')) END IS_PHANTOM FROM ABPPMGR.SUPPLYDMDPEGPLAN SD WHERE SD.DEMANDORDERID = '5000118200/660_1-MFG000'