Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8735

Query help - Backorder Report

$
0
0

Hello,

 

I am trying to write a backorder query..

 

Here is what I have currently:

 

SELECT T0.[CardCode], T0.[CardName], T0.[DocNum], sum(T1.[LineTotal]) as [order total]

FROM [dbo].[ORDR]  T0 INNER JOIN [dbo].[RDR1]  T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OWHS T3 ON T0.Filler = T3.WhsCode

WHERE T0.[CANCELED] = 'n' and T0.[DocStatus] = 'o' and T1.[PickStatus] = 'n' and T1.[OpenQty] <> 0 and (T2.[OnHand] - T2.[IsCommited] > 0 and T3.[WhsName] = 'Main Warehouse')

GROUP BY T0.[CardCode], T0.[CardName], T0.[DocNum]

ORDER BY T0.[CardCode], T0.[CardName], T0.[DocNum]

 

If I take out the WHERE clause

and (T2.[OnHand] - T2.[IsCommited] > 0 and T3.[WhsName] = 'Main Warehouse')

 

As well as take off the tables OITM and OWHS this will return a list of all open sales orders, with the sum of the open lines that aren't on a picklist.

This is part of the way there.

 

I need to return the sum of the open order lines that are in stock, which is why I have added the above WHERE clause.

 

But this doesn't work for me.

 

Can someone please assist?

 

Regards

Rick


Viewing all articles
Browse latest Browse all 8735

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>