目标:根据所选的MRP计划打印展望期中的物料欠料情况
格式:
MRP名称 |
料件 |
描述 |
采购员 |
计划员 |
请购量 |
在途量 |
HK待检 |
SZ待检 |
已检未入库 |
|||||||||||||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|||||||||||||||||||||||||||
|
|
|
|
|
|
|
|
|
|
|||||||||||||||||||||||||||
NG数量 |
原料仓 |
备料仓 |
SMT仓 |
辅料仓 |
过期需求 |
过期欠料 |
第一周需求 |
第一周欠料 |
||||||||||||||||||||||||||||
|
|
|
|
|
<04.03 |
<04.03 |
04.03-04.09 |
04.03-04.09 |
||||||||||||||||||||||||||||
第二周需求 |
第二周欠料 |
第三周需求 |
第三周欠料 |
第四周需求 |
第四周欠料 |
第五周需求 |
第五周欠料 |
|||||||||||||||||||||||||||||
04.10-04.16 |
04.10-04.16 |
04.17-04.23 |
04.17-04.23 |
04.24-04.30 |
04.24-04.30 |
05.01-05.07 |
05.01-05.07 |
|||||||||||||||||||||||||||||
第六周需求 |
第六周欠料 |
第七周需求 |
第七周欠料 |
第八周需求 |
第八周欠料 |
|||||||||||||||||||||||||||||||
05.08-05.14 |
05.08-05.14 |
05.15-05.21 |
05.15-05.21 |
05.23-05.28 |
05.23-05.28 |
|||||||||||||||||||||||||||||||
第三月需求 |
第三月欠料 |
第四月需求 |
第四月欠料 |
|||||||||||||||||||||||||||||||||
05.29-06.26 |
05.29-06.26 |
06.27-07.25 |
06.27-07.25 |
|||||||||||||||||||||||||||||||||
逻辑:
1. 欠料分析分为两个不同的时间栏:周、月。以打印时间点为基准
2. 需求为MRP平台上毛需求,也就是数量为负数那些料件
3. 料件范围:属性为MRP计划和MPS计划
4. 欠料=需求-(原材料仓+备料仓+Smt仓+辅料仓+sz待检+已检未入库)
5. 同时显示在途量,请购量,HK待检,NG数量
6.过期需求:小于运行报表日期;
第一周需求:运行报表日期7×0--运行报表日期+7×1-1
第二周需求:运行报表日期7×1--运行报表日期+7×2-1
第八周需求:运行报表日期7×7--运行报表日期+7×8-1......
第三月需求:运行报表日期+7×8--运行报表日期+7×8+29×1-1
第四月需求:运行报表日期+7×8+29×1--运行报表日期+7×8+29×2-1
欠料:累积欠料
过期欠料:小于运行报表日期;
第一周欠料:过期欠料-第一周需求量
第二周欠料:过期欠料-第一周需求量 -第二周需求量,......
[@more@]代码:SELECT MSI.ORGANIZATION_ID,
MSI.INVENTORY_ITEM_ID,
MSI1.SEGMENT1,
MSI.DESCRIPTION,
MSI.COMPILE_DESIGNATOR,
MSI.BUYER_NAME,
MSI.PLANNER_CODE,
MIN(CUX_ITEM_CHECK_IN_QTY(MSI.ORGANIZATION_ID,MSI.INVENTORY_ITEM_ID)) ITEM_CHECK_IN_QTY,
MIN(CUX_ITEM_CHECK_REJECT_QTY(MSI.ORGANIZATION_ID,MSI.INVENTORY_ITEM_ID)) ITEM_CHECK_REJECT_QTY,
MIN(CUX_ITEM_NOCHECK_HK_QTY(MSI.ORGANIZATION_ID,MSI.INVENTORY_ITEM_ID)) ITEM_NOCHECK_HK_QTY,
MIN(CUX_ITEM_NOCHECK_SZ_QTY(MSI.ORGANIZATION_ID,MSI.INVENTORY_ITEM_ID)) ITEM_NOCHECK_SZ_QTY,
MIN(CUX_ITEM_REQUISITION_QTY(MSI.ORGANIZATION_ID,MSI.INVENTORY_ITEM_ID)) ITEM_REQUISITION_QTY,
MIN(CUX_ITEM_ONROAD_QTY(MSI.ORGANIZATION_ID,MSI.INVENTORY_ITEM_ID)) ITEM_ONROAD_QTY,
MIN(NVL(CUX_ITEM_SUB_ONHAND(MSI.ORGANIZATION_ID,MSI.INVENTORY_ITEM_ID,'102001','','',''),0)) INV_MATERIAL,
MIN(NVL(CUX_ITEM_SUB_ONHAND(MSI.ORGANIZATION_ID,MSI.INVENTORY_ITEM_ID,'102091','','',''),0)) INV_PRE,
MIN(NVL(CUX_ITEM_SUB_ONHAND(MSI.ORGANIZATION_ID,MSI.INVENTORY_ITEM_ID,'102101','','',''),0)) INV_SMT,
MIN(NVL(CUX_ITEM_SUB_ONHAND(MSI.ORGANIZATION_ID,MSI.INVENTORY_ITEM_ID,'105002','','',''),0)) INV_ASS,
SUM(DECODE(SIGN(MGR.USING_ASSEMBLY_DEMAND_DATE-TRUNC(SYSDATE)),-1,USING_REQUIREMENTS_QUANTITY,0)) DUE_QTY,
SUM(DECODE(SIGN(MGR.USING_ASSEMBLY_DEMAND_DATE-TRUNC(SYSDATE+7*1)),-1,DECODE(SIGN(TRUNC(SYSDATE-1+7*0)-MGR.USING_ASSEMBLY_DEMAND_DATE),-1,USING_REQUIREMENTS_QUANTITY,0),0)) WEEK1_QTY,
SUM(DECODE(SIGN(MGR.USING_ASSEMBLY_DEMAND_DATE-TRUNC(SYSDATE+7*2)),-1,DECODE(SIGN(TRUNC(SYSDATE-1+7*1)-MGR.USING_ASSEMBLY_DEMAND_DATE),-1,USING_REQUIREMENTS_QUANTITY,0),0)) WEEK2_QTY,
SUM(DECODE(SIGN(MGR.USING_ASSEMBLY_DEMAND_DATE-TRUNC(SYSDATE+7*3)),-1,DECODE(SIGN(TRUNC(SYSDATE-1+7*2)-MGR.USING_ASSEMBLY_DEMAND_DATE),-1,USING_REQUIREMENTS_QUANTITY,0),0)) WEEK3_QTY,
SUM(DECODE(SIGN(MGR.USING_ASSEMBLY_DEMAND_DATE-TRUNC(SYSDATE+7*4)),-1,DECODE(SIGN(TRUNC(SYSDATE-1+7*3)-MGR.USING_ASSEMBLY_DEMAND_DATE),-1,USING_REQUIREMENTS_QUANTITY,0),0)) WEEK4_QTY,
SUM(DECODE(SIGN(MGR.USING_ASSEMBLY_DEMAND_DATE-TRUNC(SYSDATE+7*5)),-1,DECODE(SIGN(TRUNC(SYSDATE-1+7*4)-MGR.USING_ASSEMBLY_DEMAND_DATE),-1,USING_REQUIREMENTS_QUANTITY,0),0)) WEEK5_QTY,
SUM(DECODE(SIGN(MGR.USING_ASSEMBLY_DEMAND_DATE-TRUNC(SYSDATE+7*6)),-1,DECODE(SIGN(TRUNC(SYSDATE-1+7*5)-MGR.USING_ASSEMBLY_DEMAND_DATE),-1,USING_REQUIREMENTS_QUANTITY,0),0)) WEEK6_QTY,
SUM(DECODE(SIGN(MGR.USING_ASSEMBLY_DEMAND_DATE-TRUNC(SYSDATE+7*7)),-1,DECODE(SIGN(TRUNC(SYSDATE-1+7*6)-MGR.USING_ASSEMBLY_DEMAND_DATE),-1,USING_REQUIREMENTS_QUANTITY,0),0)) WEEK7_QTY,
SUM(DECODE(SIGN(MGR.USING_ASSEMBLY_DEMAND_DATE-TRUNC(SYSDATE+7*8)),-1,DECODE(SIGN(TRUNC(SYSDATE-1+7*7)-MGR.USING_ASSEMBLY_DEMAND_DATE),-1,USING_REQUIREMENTS_QUANTITY,0),0)) WEEK8_QTY,
SUM(DECODE(SIGN(MGR.USING_ASSEMBLY_DEMAND_DATE-TRUNC(SYSDATE+7*8+29)),-1,DECODE(SIGN(TRUNC(SYSDATE-1+7*8)-MGR.USING_ASSEMBLY_DEMAND_DATE),-1,USING_REQUIREMENTS_QUANTITY,0),0)) MONTH3_QTY,
SUM(DECODE(SIGN(MGR.USING_ASSEMBLY_DEMAND_DATE-TRUNC(SYSDATE+7*8+58)),-1,DECODE(SIGN(TRUNC(SYSDATE-1+7*8+29)-MGR.USING_ASSEMBLY_DEMAND_DATE),-1,USING_REQUIREMENTS_QUANTITY,0),0)) MONTH4_QTY--,
FROM MRP_GROSS_REQUIREMENTS MGR,
MRP_SYSTEM_ITEMS MSI,
MTL_SYSTEM_ITEMS_B MSI1
WHERE 1=1
AND MGR.COMPILE_DESIGNATOR = MSI.COMPILE_DESIGNATOR
AND MGR.ORGANIZATION_ID = MSI.ORGANIZATION_ID
AND MGR.INVENTORY_ITEM_ID = MSI.INVENTORY_ITEM_ID
AND MSI1.ORGANIZATION_ID = MSI.ORGANIZATION_ID
AND MSI1.INVENTORY_ITEM_ID = MSI.INVENTORY_ITEM_ID
--AND MSI.INVENTORY_ITEM_ID=4689
AND MSI1.ORGANIZATION_ID=:P_ORG_ID
AND MSI.COMPILE_DESIGNATOR=:P_PLAN_NAME
GROUP BY MSI.ORGANIZATION_ID,
MSI.INVENTORY_ITEM_ID,
MSI1.SEGMENT1,
MSI.DESCRIPTION,
MSI.COMPILE_DESIGNATOR,
MSI.BUYER_NAME,
MSI.PLANNER_CODE
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/41594/viewspace-1001994/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/41594/viewspace-1001994/