我有一个SAP B1查询来检查计划发送的未结订单 查询有效,但是当存在没有链接生产订单的销售订单时 该订单不会出现在列表中。仅显示包含关联生产订单的订单
有人可以帮我查询我的查询联接,以便查询结果显示已安排发送的所有订单,这些订单已经或没有链接生产订单
SELECT T0.[DocNum] as 'S/O #',
T1.[ShipDate] as 'Ship Date',
T0.[CardName] as 'Sales Partner' ,
T0.[NumAtCard] as 'Cust P/O #',
T1.[U_Type] as 'Type #',
T1.[U_Prod_Order_No] as 'Prod. Ord #',
T1.[OpenQty] as 'Qty',
T1.[ItemCode] as 'Item Code',
T1.[Dscription] as 'Item Description',
T1.[U_A1WMS_Comments],
T1.[LineTotal] as 'Row Total',
T0.[Address2] as 'Ship To Address',
T2.[Status]
FROM
ORDR T0
INNER JOIN RDR1 T1 ON T0.[DocEntry] = T1.[DocEntry]
LEFT JOIN OWOR T2 ON T0.[DocNum] = T2.[OriginNum] AND T1.[DocEntry] =
T2.[OriginAbs]
WHERE
T0.[CardCode] = T2.[CardCode] and
T1.[U_Prod_Order_No] = T2.[DocNum] and
T1. Linestatus = 'O' and T1.[ShipDate] <= [%0]
由于 拉胡
答案 0 :(得分:0)
就像Hybridzz评论所说,你的问题在于U_Prod_Order_No字段。如果您在查询中注意到,在&#34; Where&#34;声明,你有
T1.[U_Prod_Order_No] = T2.[DocNum]
让我们举例说明您没有在销售订单上填写生产订单,WHERE
将填充'' = null
之类的信息或类似的信息。
解决方案可能是将大部分WHERE
语句添加到JOIN
SELECT T0.[DocNum] as 'S/O #',
T1.[ShipDate] as 'Ship Date',
T0.[CardName] as 'Sales Partner' ,
T0.[NumAtCard] as 'Cust P/O #',
T1.[U_Type] as 'Type #',
T1.[U_Prod_Order_No] as 'Prod. Ord #',
T1.[OpenQty] as 'Qty',
T1.[ItemCode] as 'Item Code',
T1.[Dscription] as 'Item Description',
T1.[U_A1WMS_Comments],
T1.[LineTotal] as 'Row Total',
T0.[Address2] as 'Ship To Address',
T2.[Status]
FROM
ORDR T0
INNER JOIN RDR1 T1 ON T0.[DocEntry] = T1.[DocEntry]
LEFT JOIN OWOR T2 ON T0.[DocNum] = T2.[OriginNum]
AND T1.[DocEntry] = T2.[OriginAbs]
AND T0.[CardCode] = T2.[CardCode]
and T1.[U_Prod_Order_No] = T2.[DocNum]
WHERE T1. Linestatus = 'O' and T1.[ShipDate] <= [%0]