Sap Inventory Query in
Sap Inventory Query in
Sap Inventory Query in
Where N1.DocDate < @FromDate and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription Union All select N1.Warehouse, N1.Itemcode, N1.Dscription, 0 as OpeningBalance, sum(N1.inqty) , 0 as OUT From dbo.OINM N1 Where N1.DocDate >= @FromDate and N1.DocDate <= @ToDate and N1.Inqty >0 and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription Union All select N1.Warehouse, N1.Itemcode, N1.Dscription, 0 as OpeningBalance, 0 , sum(N1.outqty) as OUT From dbo.OINM N1 Where N1.DocDate >= @FromDate and N1.DocDate <=@ToDate and N1.OutQty >0 and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription) a, dbo.OITM I1 where a.ItemCode=I1.ItemCode Group By a.Itemcode Having sum(a.OpeningBalance) + sum(a.INq) + sum(a.OUT) > 0 Order By a.Itemcode
2.
SELECT --T6.PrjName, MAX(T2.DocNum) as ' PO NO', T2.DocEntry as ' PO NO Navigation', T2.DocDate as 'PoDATE', T2.CardName as 'Supplier Name', T0.Dscription as 'POItem', T0.Quantity as 'PoQty', T0.Price as 'POPrice', T0.LineTotal as 'POTot', MAX(T4.DocNum) as 'GRN No', T4.DocEntry as 'GRN No Navigation', T4.DocDate as 'GRN Date', T4.Numatcard as 'Supplier Reference No', T1.ItemCode as 'GRN Item', T1.Quantity as 'GRN Qty', T1.Price as 'GRN Price', T1.Currency as 'GRN Cur', MAX(T5.DocNum) as 'INV No', T5.DocEntry as 'INV No Navigation', T5.DocDate as 'INV Date', T5.Numatcard as 'Supplier Reference No', T3.Quantity as 'INV Qty', T3.Price as 'INV Price', T3.Currency as 'INV Cur', T3.LineTotal as 'INV Tot', T5.PaidtoDate as 'Paid Sum', (T3.LineTotal - T5.PaidtoDate) as 'Balance Due', --T7.CheckNum AS 'CheckNo', --T7.DueDate as 'CheckDate', --T7.CheckSum as 'CheckSum',
--T8.Cashsum as 'Cash Amount', T2.DocStatus AS ' PO Document Status' FROM POR1 T0 INNER JOIN PDN1 T1 ON T0.TrgetEntry = T1.DocEntry AND T0.Itemcode = T1.ItemCode AND T0.LineNum = T1.Baseline AND T0.DocEntry = T1.BaseEntry INNER JOIN OPOR T2 ON T0.DocEntry = T2.DocEntry INNER JOIN PCH1 T3 ON T1.TrgetEntry = T3.DocEntry AND T1.ItemCode = T3.ItemCode AND T1.LineNum = T3.Baseline AND T1.DocEntry = T3.BaseEntry INNER JOIN OPDN T4 ON T1.DocEntry = T4.DocEntry INNER JOIN OPCH T5 ON T3.DocEntry = T5.DocEntry left outer JOIN OPRJ T6 ON T2.PROJECT = T6.PRJCODE LEFT OUTER join VPM1 T7 on T7.DOCNUM = T5.RECEIPTNUM LEFT OUTER JOIN OVPM T8 on T8.DocEntry = T5.DepositNum WHERE T0.[DocDate] >='[%0]' and T0.[DocDate] <='[%1]' GROUP BY --T6.PrjName, T2.DocNum, T2.DocEntry, T2.DocDate, T2.CardName, T0.Dscription, T0.Quantity, T0.Price, T0.LineTotal,
M.DocTotal as 'Total (Rs.)' FROM OPCH M LEFT OUTER JOIN PCH1 L on L.DocEntry=M.DocEntry LEFT OUTER JOIN PCH4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum LEFT OUTER JOIN PCH5 J ON M.DocEntry = J.AbsEntry LEFT OUTER JOIN PCH3 Q ON M.DocEntry = Q.DocEntry WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]') AND L.TargetType<>'19' GROUP BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.Doccur,M.DiscSum,M.WTSum,M. DocTotal ORDER BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.Doccur,M.DiscSum,M.WTSum,M. DocTotal