Actual Delivery Per whscode

SELECT T0.[docentry] As ‘Num’, T0.[CreateDate], T0.[DocDate], T0.[DocNum] as ‘No. DO’, T1.[BaseDocNum] as ‘No. SO’, T0.[CardCode] As ‘BP Code’, T0.[CardName], T0.[NumAtCard], T1.[WhsCode] as ‘WHSE’, T1.[ItemCode], T1.[Dscription], t0.comments, T1.[Quantity], T1.[Price], T1.OCRCODE AS ‘PLANT’, T3.docnum as [No. return], t2.quantity as [Qty Return], ISNULL(T1.[Quantity]-T2.[Quantity],T1.[Quantity]) AS [NET QTY]

 

FROM ODLN T0

left JOIN DLN1 T1 ON T0.DocEntry = T1.DocEntry

LEFT JOIN RDN1 T2 ON T0.DOCENTRY=T2.BASEENTRY

LEFT JOIN ORDN T3 ON T2.[DocEntry] = T3.[DocEntry]

 

 

 

WHERE T0.[DocDate] between [%0] and [%1] and left(t1.whscode,3) = [%2] and T0.[Canceled] = ‘N’

Open po per vendor

SELECT DISTINCT T1.[DocEntry] AS [ID PO],T0.[DocDate],  T0.[DocNum] as [NO PO], T0.[DocType] AS [TYPE], T1.[ItemCode], T1.[Dscription], T1.[Quantity], t2.docentry AS [ID GR], T2.[DocNum] AS [NO GRPO], T3.DSCRIPTION, T3.QUANTITY AS [QTY GR], T3.BASEOPNQTY – T3.QUANTITY AS [SISA PO]

 

FROM

OPOR T0

LEFT JOIN POR1 T1 ON T0.[DocEntry] = T1.[DocEntry]

LEFT JOIN PDN1 T3 ON T3.baseENTRY = T1.docENTRY and T3.baseline = T1.LINENUM

LEFT JOIN OPDN T2 ON T2.[DocEntry] = T3.[DocEntry]

 

 

WHERE T0.[CANCELED] =’n’ and  T0.[DocStatus] =’o’ and T0.[cardname] =[%0]

can be used for SO too