将交付信息添加到SAP Crystal Reports中的查询

时间:2017-03-07 01:21:11

标签: sql crystal-reports sap business-intelligence

以下是将采购订单与销售订单相关联的查询。我的理解是,为了将交付文档#包含在此报告中,我需要再添加一个表 - ODLN (因此会有一个标题为&#34的附加字段;交付文档#&#34 ;又名[ODLN.DocNum])。我的问题是我不确定如何在下面的查询中加入ODLN而不会弄乱任何东西。

ODLN.DocNum几乎验证了PO在SO提交时确实被放置了。

SELECT DISTINCT
       o.CardName AS 'Customer Name'
       ,(isnull(c1.Street,'') + ', ' + isnull(c1.Block,'') + ', ' + isnull(c1.City,'') + ', ' + isnull(c1.[State],'') + ' ' + isnull(c1.ZipCode,'')) AS 'Customer Address'
       ,cpr.[Name] AS 'Customer Contact'
       ,cpr.Tel1 AS 'Customer Phone'
       ,cpr.E_MailL AS 'Customer Email'
       ,o.DocNum AS 'Sales Order #'
       ,p.DocNum AS 'PO # to Barracuda'
       ,l.ItemCode AS 'SKU'
       ,l.Dscription AS 'Desc'
       ,l.Quantity AS 'Qty'
       ,l.Price
       ,s.SlpName AS 'Sales Rep'
FROM 
       ORDR o
       INNER JOIN RDR1 l ON o.DocEntry = l.DocEntry
       LEFT JOIN POR1 p1 ON l.DocEntry = p1.BaseEntry AND l.LineNum = p1.BaseLine
       LEFT JOIN OPOR p ON p1.DocEntry = p.DocEntry
       INNER JOIN OCRD c ON o.CardCode = c.CardCode
       INNER JOIN CRD1 c1 ON c.CardCode = c1.CardCode AND c.BillToDef = c1.[Address]
       LEFT JOIN OCPR cpr ON c.CntctPrsn = cpr.[Name] AND c.CardCode = cpr.CardCode
       INNER JOIN OITM itm ON l.ItemCode = itm.ItemCode
       INNER JOIN OITB i ON itm.ItmsGrpCod = i.itmsGrpCod
       INNER JOIN OSLP s ON o.SlpCode = s.SlpCode
WHERE
       o.Canceled = 'N'
       AND c1.AdresType = 'B'
       AND i.ItmsGrpCod = 109
       AND o.DocDate BETWEEN '6/01/2014 00:00:00.000' AND '9/30/2014 00:00:00.000'
ORDER BY
       o.DocNum

1 个答案:

答案 0 :(得分:0)

从评论中可以清楚地看出,您无法确定将ODLN加入当前查询的字段。

我会跟着钱。

如果我没记错的话,ODLN.TransId加入OJDT.TransId,OJDT.BaseRef加入OPOR.DocNum。

您的问题中不清楚的是,您是否只需要那些拥有交付文档的订阅源,只有那些没有订阅的订阅源,或者所有采购订单(订购或不订购,具有交付文档的订单)。一旦我们知道了,我们可以告诉你是使用左还是内,如何处理Null等等。坦率地说,当涉及到SAP时,那部分是微不足道的。