Commit cdd1cc0d authored by cpatil's avatar cpatil

merge from supreme release


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@101433 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 88ac7ff3
select item_code, due_date, round(sum(demand),0) demand, sum(supply) supply from ( select item_code, due_date, round(sum(demand),0) demand, sum(supply) supply , sum(stock_qty) stock_qty, sum(oth_supply) oth_supply, sum(pending_po) pending_po ,sum(pending_do) pending_do, sum(pending_indent) pending_indent, sum(pending_dr) pending_drfrom (
SELECT item.item_code__plan as item_code,independent_demand.due_date as due_date, sum(case when independent_demand.quantity__std_uom is null then 0 else independent_demand.quantity__std_uom end) SELECT item.item_code__plan as item_code,independent_demand.due_date as due_date, sum(case when independent_demand.quantity__std_uom is null then 0 else independent_demand.quantity__std_uom end)
as demand, 0 as supply as demand, 0 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM independent_demand, item FROM independent_demand, item
WHERE ( independent_demand.item_code = item.item_code ) and WHERE ( independent_demand.item_code = item.item_code ) and
( independent_demand.site_code in ('@sitecode@') ) AND ( independent_demand.site_code in ('@sitecode@') ) AND
...@@ -12,7 +12,7 @@ SELECT item.item_code__plan as item_code,independent_demand.due_date as due_date ...@@ -12,7 +12,7 @@ SELECT item.item_code__plan as item_code,independent_demand.due_date as due_date
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code, sales_demand.due_date as due_date, SELECT item.item_code__plan as item_code, sales_demand.due_date as due_date,
sum(case when sales_demand.quantity__std_uom is null then 0 else sales_demand.quantity__std_uom end - case sum(case when sales_demand.quantity__std_uom is null then 0 else sales_demand.quantity__std_uom end - case
when sales_demand.consumed_qty is null then 0 else sales_demand.consumed_qty end ) as demand, 0 as supply when sales_demand.consumed_qty is null then 0 else sales_demand.consumed_qty end ) as demand, 0 as supply , 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM sales_demand, item FROM sales_demand, item
WHERE ( sales_demand.item_code = item.item_code ) and WHERE ( sales_demand.item_code = item.item_code ) and
( sales_demand.site_code in ('@sitecode@') ) AND ( sales_demand.site_code in ('@sitecode@') ) AND
...@@ -22,7 +22,8 @@ UNION ALL ...@@ -22,7 +22,8 @@ UNION ALL
Group By item.item_code__plan,sales_demand.due_date Group By item.item_code__plan,sales_demand.due_date
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code, distorder_det.due_date as due_date, SELECT item.item_code__plan as item_code, distorder_det.due_date as due_date,
sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as demand, 0 as supply sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as demand, 0 as supply,
0 as stock_qty, 0 as oth_supply, 0 as pending_po, sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as pending_do, 0 as pending_indent, 0 as pending_dr
FROM distorder,distorder_det, item FROM distorder,distorder_det, item
WHERE ( distorder_det.item_code = item.item_code ) and WHERE ( distorder_det.item_code = item.item_code ) and
( distorder.dist_order = distorder_det.dist_order ) and ( distorder.dist_order = distorder_det.dist_order ) and
...@@ -37,7 +38,8 @@ UNION ALL ...@@ -37,7 +38,8 @@ UNION ALL
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code, sorditem.due_date as due_date, sum((case when sorditem.quantity is null then 0 else sorditem.quantity end - case when sorditem.qty_alloc is null then 0 SELECT item.item_code__plan as item_code, sorditem.due_date as due_date, sum((case when sorditem.quantity is null then 0 else sorditem.quantity end - case when sorditem.qty_alloc is null then 0
else sorditem.qty_alloc end - case when sorditem.qty_desp is null then 0 else sorditem.qty_alloc end - case when sorditem.qty_desp is null then 0
else sorditem.qty_desp end ) * case when sorditem.conv__qty_stdqty is null then 1 else sorditem.conv__qty_stdqty end ) as demand, 0 as supply else sorditem.qty_desp end ) * case when sorditem.conv__qty_stdqty is null then 1 else sorditem.conv__qty_stdqty end ) as demand, 0 as supply ,
0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM sorder,sorditem, item FROM sorder,sorditem, item
WHERE ( sorditem.item_code = item.item_code ) and(sorder.sale_order = sorditem.sale_order ) and WHERE ( sorditem.item_code = item.item_code ) and(sorder.sale_order = sorditem.sale_order ) and
(case when sorder.confirmed is null then 'N' else sorder.confirmed end = 'Y' ) and (case when sorder.confirmed is null then 'N' else sorder.confirmed end = 'Y' ) and
...@@ -49,7 +51,8 @@ Group By item.item_code__plan,sorditem.due_date ...@@ -49,7 +51,8 @@ Group By item.item_code__plan,sorditem.due_date
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code, distorder_det.due_date as due_date, SELECT item.item_code__plan as item_code, distorder_det.due_date as due_date,
0 as demand, 0 as demand,
sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_received is null then 0 else qty_received end ) as supply sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_received is null then 0 else qty_received end ) as supply,
0 as stock_qty, sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_received is null then 0 else qty_received end ) as oth_supply, 0 as pending_po, sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as pending_dr, 0 as pending_indent, 0 as pending_dr
FROM distorder,distorder_det, item FROM distorder,distorder_det, item
WHERE ( distorder_det.item_code = item.item_code ) WHERE ( distorder_det.item_code = item.item_code )
and ( distorder.dist_order = distorder_det.dist_order ) and ( distorder.dist_order = distorder_det.dist_order )
...@@ -67,6 +70,7 @@ UNION ALL ...@@ -67,6 +70,7 @@ UNION ALL
sum(case when (case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 sum(case when (case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0
else porddet.dlv_qty end) < 0 then 0 else case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end) < 0 then 0 else case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0
else porddet.dlv_qty end end ) as supply else porddet.dlv_qty end end ) as supply
0 as stock_qty, sum(case when (case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end) < 0 then 0 else case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end end ) as oth_supply, sum(case when (case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end) < 0 then 0 else case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end end ) as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM porddet,porder, item FROM porddet,porder, item
WHERE ( porddet.item_code = item.item_code ) WHERE ( porddet.item_code = item.item_code )
and (porddet.purc_order = porder.purc_order ) and (porddet.purc_order = porder.purc_order )
...@@ -78,18 +82,43 @@ WHERE ( porddet.item_code = item.item_code ) ...@@ -78,18 +82,43 @@ WHERE ( porddet.item_code = item.item_code )
and ( porder.pord_type not in (@ordtypes@) ) and ( porder.pord_type not in (@ordtypes@) )
and ( porddet.dlv_date <= timestamp('@todate@-00.00.00')) and ( porddet.dlv_date <= timestamp('@todate@-00.00.00'))
Group By item.item_code__plan,porddet.dlv_date Group By item.item_code__plan,porddet.dlv_date
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code, FN_MRP_DUEDATE(timestamp('@fromdate@-00.00.00')) as due_date,
0 as demand , select item_code,due_date,sum(demand) demand,sum(supply) supply,sum(stock_qty) stock_qty,
DDF_INV_CLSTK_MRP('@sitecode@', sum(oth_supply) oth_supply,sum(pending_po) pending_po,sum(pending_do) pending_do,sum(pending_indent) pending_indent,
item.item_code, sum(pending_dr) pending_dr from
timestamp(fn_sysdate())) as supply ( SELECT d.item_code__plan as item_code,FN_MRP_DUEDATE(timestamp('@fromdate@-00.00.00')) as due_date,0 as demand,
FROM item (a.quantity-a.alloc_qty) as supply,(a.quantity-a.alloc_qty) as stock_qty,
WHERE item.item_code = '@itemcode@' 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
and DDF_INV_CLSTK_MRP('@sitecode@',item.item_code,timestamp(fn_sysdate())) > 0 FROM STOCK a, INVSTAT b , LOCATION c,item d
WHERE a.loc_code = c.loc_code
AND b.inv_stat = c.inv_stat
AND NVL(b.stat_type, ' ') <> 'S'
AND a.site_code = '@sitecode@'
AND a.item_code = '@itemcode@'
AND NVL(b.plan_prod,'N') = 'Y'
AND a.item_code=d.item_code
UNION ALL
SELECT d.item_code__plan as item_code,FN_MRP_DUEDATE(timestamp(('@fromdate@-00.00.00')) as due_date,0 as demand,
NVL((eff_qty * -1),0) as supply,NVL((eff_qty * -1),0) as stock_qty,
0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM INVTRACE a, LOCATION b, INVSTAT c,item d
WHERE a.loc_code = b.loc_code
AND b.inv_stat = c.inv_stat
AND NVL(c.stat_type, ' ') <> 'S'
AND a.item_code = '@itemcode@'
AND a.site_code = '@sitecode@'
AND NVL(c.plan_prod,'N') = 'Y'
AND a.item_code=d.item_code
AND a.EFF_date > timestamp(fn_sysdate())) group by item_code,due_date
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code, timestamp('@fromdate@-00.00.00') as due_date, SELECT item.item_code__plan as item_code, timestamp('@fromdate@-00.00.00') as due_date,
0 as demand,sum((case when workorder.current_batch_qty is null then 0 else workorder.current_batch_qty end * case when workorder.yield_perc is null then 100 else workorder.yield_perc end / 100 ) - case when workorder.quantity__rcvd is null then 0 else workorder.quantity__rcvd end ) as supply 0 as demand,sum((case when workorder.current_batch_qty is null then 0 else workorder.current_batch_qty end * case when workorder.yield_perc is null then 100 else workorder.yield_perc end / 100 ) - case when workorder.quantity__rcvd is null then 0 else workorder.quantity__rcvd end ) as supply ,
0 as stock_qty, sum((case when workorder.current_batch_qty is null then 0 else workorder.current_batch_qty end * case when workorder.yield_perc is null then 100 else workorder.yield_perc end / 100 ) - case when workorder.quantity__rcvd is null then 0 else workorder.quantity__rcvd end ) as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM workorder, item FROM workorder, item
WHERE ( workorder.item_code = item.item_code ) WHERE ( workorder.item_code = item.item_code )
and ( workorder.site_code in ('@sitecode@') ) and ( workorder.site_code in ('@sitecode@') )
...@@ -102,7 +131,7 @@ UNION ALL ...@@ -102,7 +131,7 @@ UNION ALL
SELECT workorder_bill.item_code as item_code, timestamp('@fromdate@-00.00.00') as due_date, SELECT workorder_bill.item_code as item_code, timestamp('@fromdate@-00.00.00') as due_date,
sum( case when workorder_bill.QUANTITY is null then 0 else workorder_bill.QUANTITY end - case when (case when workorder_bill.ALLOC_QTY is null then 0 else workorder_bill.ALLOC_QTY end - case when workorder_bill.ISS_QTY is null then 0 sum( case when workorder_bill.QUANTITY is null then 0 else workorder_bill.QUANTITY end - case when (case when workorder_bill.ALLOC_QTY is null then 0 else workorder_bill.ALLOC_QTY end - case when workorder_bill.ISS_QTY is null then 0
else workorder_bill.ISS_QTY end) < 0 then case when workorder_bill.ISS_QTY is null then 0 else workorder_bill.ISS_QTY end else case when workorder_bill.ALLOC_QTY is null then 0 else workorder_bill.ALLOC_QTY end end ) as demand, else workorder_bill.ISS_QTY end) < 0 then case when workorder_bill.ISS_QTY is null then 0 else workorder_bill.ISS_QTY end else case when workorder_bill.ALLOC_QTY is null then 0 else workorder_bill.ALLOC_QTY end end ) as demand,
0 as supply 0 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
from workorder_bill, workorder, item, siteitem from workorder_bill, workorder, item, siteitem
where workorder_bill.work_order = workorder.work_order where workorder_bill.work_order = workorder.work_order
and workorder_bill.item_code = item.item_code and workorder_bill.item_code = item.item_code
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment