Commit 73eb1992 authored by prane's avatar prane

Changes related to forecast(salesforecast_hdr) added

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@202691 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8eab9043
...@@ -24,9 +24,22 @@ ...@@ -24,9 +24,22 @@
( sales_demand.due_date <= to_date('@todate@')) AND ( sales_demand.due_date <= to_date('@todate@')) AND
( 0 = @madetostock@ ) ( 0 = @madetostock@ )
Group By sales_demand.tran_id,'S-FCT',item.item_code__plan,sales_demand.due_date Group By sales_demand.tran_id,'S-FCT',item.item_code__plan,sales_demand.due_date
UNION ALL
SELECT h.tran_id, 'S-FST' as tran_ser, item.item_code__plan as item_code,fn_get_prdfrdate(d.PRD_CODE__FOR) as due_date,
sum(fn_get_avgpotency('@itemcode@' ,'@sitecode@',case when d.quantity is null then 0 else d.quantity end )) as demand ,
0 as supply
FROM salesforecast_det d,salesforecast_hdr h, item
WHERE ( h.tran_id = d.tran_id ) and
( d.item_code = item.item_code ) and
( h.site_code in ('@sitecode@') ) AND
( item.item_code__plan = '@itemcode@') AND
( (select fr_date from period where code = d.PRD_CODE__FOR) >= to_date('@fromdate@')) AND
( (select to_date from period where code = d.PRD_CODE__FOR) <= to_date('@todate@')) AND
( 0 = @madetostock@ )
and trim(nvl((select si.mfg_type from siteitem si where si.site_code = h.site_code and si.item_code = item.item_code ),' ')) not in ('O','D')
Group By h.TRAN_ID, 'S-FST', item.item_code__plan,fn_get_prdfrdate(d.PRD_CODE__FOR)
UNION ALL UNION ALL
SELECT distorder.dist_order||'@'||distorder_det.line_no tran_id,'Dist Order' as tran_ser, item.item_code__plan as item_code,distorder_det.due_date as due_date, SELECT distorder.dist_order||'@'||distorder_det.line_no tran_id, 'Dist Order' as tran_ser, 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, 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 supply
FROM distorder,distorder_det, item FROM distorder,distorder_det, item
...@@ -43,7 +56,7 @@ ...@@ -43,7 +56,7 @@
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code,distorder_det.due_date as due_date, SELECT distorder.dist_order||'@'||distorder_det.line_no tran_id, 'Dist Order' as tran_ser, 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
FROM distorder,distorder_det, item FROM distorder,distorder_det, item
...@@ -56,7 +69,7 @@ ...@@ -56,7 +69,7 @@
( distorder.order_type not in (@ordtypes@) ) and ( distorder.order_type not in (@ordtypes@) ) and
( case when distorder.status is null then 'P' else distorder.status end = 'P') AND ( case when distorder.status is null then 'P' else distorder.status end = 'P') AND
(case when qty_confirm is null then 0 else qty_confirm end - case when qty_received is null then 0 else qty_received end ) > 0 (case when qty_confirm is null then 0 else qty_confirm end - case when qty_received is null then 0 else qty_received end ) > 0
Group By item.item_code__plan,distorder_det.due_date Group By distorder.dist_order||'@'||distorder_det.line_no , 'Dist Order',item.item_code__plan,distorder_det.due_date
UNION ALL UNION ALL
...@@ -78,7 +91,7 @@ ...@@ -78,7 +91,7 @@
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date, SELECT '' as tran_id, '' as tran_ser, item.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,
0 as demand , 0 as demand ,
DDF_INV_CLSTK_MRP('@sitecode@',item.item_code,to_date(fn_sysdate())) as supply DDF_INV_CLSTK_MRP('@sitecode@',item.item_code,to_date(fn_sysdate())) as supply
FROM item FROM item
......
...@@ -17,6 +17,20 @@ ...@@ -17,6 +17,20 @@
( case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) > 0 ( case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) > 0
Group By distorder.dist_order||'@'||distorder_det.line_no,'Dist Order', item.item_code__plan,distorder_det.due_date Group By distorder.dist_order||'@'||distorder_det.line_no,'Dist Order', item.item_code__plan,distorder_det.due_date
UNION ALL
SELECT h.tran_id, 'S-FST' as tran_ser, item.item_code__plan as item_code,fn_get_prdfrdate(d.PRD_CODE__FOR) as due_date,
sum(fn_get_avgpotency('@itemcode@' ,'@sitecode@',case when d.quantity is null then 0 else d.quantity end )) 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 salesforecast_det d,salesforecast_hdr h, item
WHERE ( h.tran_id = d.tran_id ) and
( d.item_code = item.item_code ) and
( h.site_code in ('@sitecode@') ) AND
( item.item_code__plan = '@itemcode@') AND
( (select fr_date from period where code = d.PRD_CODE__FOR) >= to_date('@fromdate@')) AND
( (select to_date from period where code = d.PRD_CODE__FOR) <= to_date('@todate@')) AND
( 0 = @madetostock@ )
and trim(nvl((select si.mfg_type from siteitem si where si.site_code = h.site_code and si.item_code = item.item_code ),' ')) not in ('O','D')
Group By h.TRAN_ID, 'S-FST', item.item_code__plan,fn_get_prdfrdate(d.PRD_CODE__FOR)
UNION ALL UNION ALL
SELECT distorder.dist_order||'@'||distorder_det.line_no tran_id,'Dist Order' as tran_ser, item.item_code__plan as item_code,distorder_det.due_date as due_date, SELECT distorder.dist_order||'@'||distorder_det.line_no tran_id,'Dist Order' as tran_ser, item.item_code__plan as item_code,distorder_det.due_date as due_date,
...@@ -82,7 +96,7 @@ SELECT indent.ind_no tran_id ,'Indent' as tran_ser ,item.item_code__plan as i ...@@ -82,7 +96,7 @@ SELECT indent.ind_no tran_id ,'Indent' as tran_ser ,item.item_code__plan as i
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date, SELECT '' as tran_id, '' as tran_ser,item.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,
0 as demand , 0 as demand ,
DDF_INV_CLSTK_MRP('@sitecode@',item.item_code,to_date(fn_sysdate())) 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 DDF_INV_CLSTK_MRP('@sitecode@',item.item_code,to_date(fn_sysdate())) 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 item FROM item
...@@ -91,7 +105,7 @@ SELECT indent.ind_no tran_id ,'Indent' as tran_ser ,item.item_code__plan as i ...@@ -91,7 +105,7 @@ SELECT indent.ind_no tran_id ,'Indent' as tran_ser ,item.item_code__plan as i
UNION ALL UNION ALL
SELECT item.item_code__plan as item_code, mps_order.due_date as due_date, SELECT mps_order.tran_id, 'MPS-ORD' as tran_ser,item.item_code__plan as item_code, mps_order.due_date as due_date,
sum(mps_order.quantity) 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 sum(mps_order.quantity) 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 mps_order, item FROM mps_order, item
WHERE ( mps_order.item_code = item.item_code ) and WHERE ( mps_order.item_code = item.item_code ) and
...@@ -100,8 +114,8 @@ UNION ALL ...@@ -100,8 +114,8 @@ UNION ALL
(mps_order.due_date >= to_date('@fromdate@')) AND (mps_order.due_date >= to_date('@fromdate@')) AND
(mps_order.due_date <= to_date('@todate@')) AND (mps_order.due_date <= to_date('@todate@')) AND
( case when mps_order.status is null then 'P' else mps_order.status end in ('P','T','M')) ( case when mps_order.status is null then 'P' else mps_order.status end in ('P','T','M'))
Group By item.item_code__plan, mps_order.due_date Group By mps_order.tran_id, 'MPS-ORD',item.item_code__plan, mps_order.due_date
) )
group by item_code,due_date group by item_code,due_date,tran_id,tran_ser
having sum(demand) <> 0 or sum(supply) <> 0 having sum(demand) <> 0 or sum(supply) <> 0
\ No newline at end of file
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