Commit 3933f5a2 authored by steurwadkar's avatar steurwadkar

Changed by Santosh added new SQL qurey


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@101128 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a36b4608
...@@ -181,18 +181,28 @@ public class DDUpdStockSchedule implements Schedule ...@@ -181,18 +181,28 @@ public class DDUpdStockSchedule implements Schedule
*/ */
//Added Nvl() to hold_qty to retrun 0 if hold_qty is null in stock master by Santosh on 06-04-2016 //Added Nvl() to hold_qty to retrun 0 if hold_qty is null in stock master by Santosh on 06-04-2016
//sql = " select A.Item_code, A.stk_qty- Nvl(H.Order_QTY,0) FinStk from (select stk.Item_code, sum(quantity-Alloc_Qty-Hold_qty) stk_qty " //sql = " select A.Item_code, A.stk_qty- Nvl(H.Order_QTY,0) FinStk from (select stk.Item_code, sum(quantity-Alloc_Qty-Hold_qty) stk_qty "
sql = " select A.Item_code, A.stk_qty- Nvl(H.Order_QTY,0) FinStk from (select stk.Item_code, sum(quantity-Alloc_Qty-Nvl(Hold_qty,0)) stk_qty "
//Changed by Santosh on 06-04-2016 [Start]
/*sql = " select A.Item_code, A.stk_qty- Nvl(H.Order_QTY,0) FinStk from (select stk.Item_code, sum(quantity-Alloc_Qty-Nvl(Hold_qty,0)) stk_qty "
+ " from stock Stk group by stk.Item_code) A left outer join (select G.item_code,G.Order_QTY from (select item_code, Sum(Quantity) Order_QTY, " + " from stock Stk group by stk.Item_code) A left outer join (select G.item_code,G.Order_QTY from (select item_code, Sum(Quantity) Order_QTY, "
+ " (select sum(quantity) from stock Stk where stk.Item_code = S.Item_code) as Stock_Qty from sorddet S, Sorder SO " + " (select sum(quantity) from stock Stk where stk.Item_code = S.Item_code) as Stock_Qty from sorddet S, Sorder SO "
+ " where SO.Sale_order=S.Sale_order and SO.Confirmed = ? and SO.Status not in (?, ?) and " + " where SO.Sale_order=S.Sale_order and SO.Confirmed = ? and SO.Status not in (?, ?) and "
+ " (select count(1) from sordalloc a where a.sale_order = s.sale_order and Trim(s.line_no) = Trim(a.line_no)) = 0 and S.status not in (?, ?) " + " (select count(1) from sordalloc a where a.sale_order = s.sale_order and Trim(s.line_no) = Trim(a.line_no)) = 0 and S.status not in (?, ?) "
+ " group by item_code) G ) H on A.Item_code = H.Item_code "; + " group by item_code) G ) H on A.Item_code = H.Item_code ";*/
sql = " SELECT SKU, SUM(FINSTK) FINSTK FROM ( SELECT S.ITEM_CODE SKU, SUM(S.QUANTITY - S.ALLOC_QTY - CASE WHEN S.HOLD_QTY IS NULL THEN 0 ELSE S.HOLD_QTY END) FINSTK "
+ " FROM STOCK S GROUP BY S.ITEM_CODE HAVING SUM(S.QUANTITY - S.ALLOC_QTY - CASE WHEN S.HOLD_QTY IS NULL THEN 0 ELSE S.HOLD_QTY END) > 0 "
+ " UNION ALL SELECT SI.ITEM_CODE, -1 * SUM(SI.QUANTITY - SI.QTY_ALLOC - SI.QTY_DESP) FROM SORDITEM SI , SORDER S, SORDDET SD "
+ " WHERE SI.SALE_ORDER = S.SALE_ORDER AND SI.SALE_ORDER = SD.SALE_ORDER AND SI.LINE_NO = SD.LINE_NO AND SI.LINE_TYPE = 'I' "
+ " AND S.STATUS NOT IN ('C','X') AND SI.STATUS NOT IN ('C','X') AND SD.STATUS NOT IN ('C','X') "
+ " GROUP BY SI.ITEM_CODE HAVING SUM(SI.QUANTITY - SI.QTY_ALLOC - SI.QTY_DESP) <> 0 ) GROUP BY SKU HAVING SUM(FINSTK) > 0 ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "Y"); /*pstmt.setString(1, "Y");
pstmt.setString(2, "X"); pstmt.setString(2, "X");
pstmt.setString(3, "C"); pstmt.setString(3, "C");
pstmt.setString(4, "X"); pstmt.setString(4, "X");
pstmt.setString(5, "C"); pstmt.setString(5, "C");*/
//Changed by Santosh on 06-04-2016 [End]
// Changed by Sneha on 11-03-2016, Change the sql [End] // Changed by Sneha on 11-03-2016, Change the sql [End]
//Changed by Samadhan D15IKAT004 on 10/12/2015 for getting Record Not in 'DOCK','ISTAG','NOSL','INTR' as per nilay and shailesh sir End //Changed by Samadhan D15IKAT004 on 10/12/2015 for getting Record Not in 'DOCK','ISTAG','NOSL','INTR' as per nilay and shailesh sir End
......
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