Skip to Content
0

Query to find PO number related to Drop Ship Delivery or Batch

May 15, 2017 at 01:37 PM

35

avatar image

I need help figuring out why the query below doesn't allow me to show T3.BsDocType and T3.BasDocEntry. It shows -1 on both of those - it doesn't seem to make sense.

SELECT T0.DocNum,
       T0.DocDate,
       T0.CardCode,
       T0.CardName,
       T1.ItemCode,
       T1.DropShip,
       T1.Dscription,
       T2.Quantity,
       T2.BatchNum,
       T0.Comments,
       t1.WhsCode,
       t2.BaseType,
       'DocEntry' = CASE
                        WHEN T1.DropShip='N' THEN T3.BaseEntry
                        ELSE T1.DocEntry
                    END,
                    'DocType' = CASE
                                    WHEN T1.DropShip='N' THEN t3.BaseType
                                    ELSE T1.BaseType
                                END
FROM ODLN T0
INNER JOIN DLN1 T1 ON T1.DocEntry = T0.DocEntry
LEFT JOIN IBT1 T2 ON T2.BaseEntry = T0.DocEntry
AND T2.BaseType = 15
AND T2.BaseLinNum = T1.LineNum
LEFT JOIN IBT1 T3 ON T2.BatchNum = T3.BatchNum
AND (T3.[BaseType] =20
     OR T3.[BaseType]=310000001
     OR T3.[BaseType]=10000071)
AND T2.ItemCode = T3.ItemCode
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers