SAP Business One 中销售订单、交货和发票之间的 link 是什么

What is the link in SAP Business One between Sales Orders, Deliveries, and Invoices

我正在尝试在 SAP Business One 查询中加入 ORDRODLNOINV,但我似乎找不到它们共有的字段.

某处一定有一些记录将一个链接到另一个。

它们是否通过单独的 table 链接?还是我遗漏了一些明显的东西?

我使用 SAP HANA 作为我的数据库,因此首选 HANA 查询而不是 MSSQL。

请检查https://archive.sap.com/discussions/thread/1440163 给出以下关系

 SELECT Distinct(T0.DocNum ),T0.DocDate, T0.CardCode, T0.CardName, T1.ItemCode, T1.Quantity, T1.Price,T1.TotalSumSy, T0.DocTotal
    FROM ORDR T0 
    INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry 
    INNER JOIN ODLN T2 ON T2.DocEntry = T1.TrgetEntry
    INNER JOIN DLN1 T3 on T3.DocEntry = T2.Docentry
    INNER JOIN OINV T4 ON T4.DocEntry = T3.TrgetEntry
    INNER JOIN INV1 T5 ON T5.DocEntry = T4.DocEntry
    LEFT JOIN ORDN T6 ON T6.DocEntry = T5.TrgetEntry
    LEFT JOIN RDN1 T7 ON T7.DocEntry = T6.DocEntry

所以下面的关系也是成立的

SELECT *
FROM ODLN T2 
INNER JOIN DLN1 T3 on T3.DocEntry = T2.Docentry
INNER JOIN OINV T4 ON T4.DocEntry = T3.TrgetEntry

首先,感谢 Eralper 他们的回答,因为其中包含的 link 帮助我找到了我正在寻找的解决方案。但是,他们的解决方案不包括解释,也没有完全给出正在寻找的结果。


SAP 中销售订单的主要信息存储在两个 table 中,ORDRRDR1ORDR 每个销售订单一行,而 RDR1 销售订单上每个产品行一行。

交货单和发票(基本上是 SAP 中的任何文档)都遵循此模式。

为什么这对这个问题很重要?因为包含 link 销售订单、送货单和发票数据的列位于 RDR1(或类似变体)中。它的名字是 TrgetEntry.

由于销售订单上的每个产品都有一行,我们不能简单地进行联接,因为任何具有多个产品的销售订单都会在结果中出现多次。以下查询使用分组来显示每个销售订单都有一行的 table,并且具有 link 到送货单所需的信息。

SELECT T0."DocEntry" AS "SO DE", T0."DocNum" AS "Sales Order Number", T1."TrgetEntry" AS "SO TE", COUNT(T0."DocNum") AS "Rows"
FROM ORDR T0
LEFT JOIN RDR1 T1 ON T0."DocEntry" = T1."DocEntry"
GROUP BY T0."DocEntry", T0."DocNum", T1."TrgetEntry"

只需更改 table 名称,就可以为送货单和发票创建类似的查询。

然后就可以用TrgetEntryDocEntry来link各种结果了。

我用来显示销售订单及其相关交货和发票的最终代码如下:

SELECT S0."SalesOrderNumber", S1."DeliveryNumber", S2."DocNum" AS "InvoiceNumber", S0."Rows", S2."DocTotal"
FROM (SELECT T0."DocEntry" AS "SO_DE", T0."DocNum" AS "SalesOrderNumber", T1."TrgetEntry" AS "SO_TE", COUNT(T0."DocNum") AS "Rows"
FROM ORDR T0
LEFT JOIN RDR1 T1 ON T0."DocEntry" = T1."DocEntry"
GROUP BY T0."DocEntry", T0."DocNum", T1."TrgetEntry") S0
LEFT JOIN (SELECT T0."DocEntry" AS "DN_DE", T0."DocNum" AS "DeliveryNumber", T1."TrgetEntry" AS "DN_TE"
FROM ODLN T0
LEFT JOIN DLN1 T1 ON T0."DocEntry" = T1."DocEntry"
GROUP BY T0."DocEntry", T0."DocNum", T1."TrgetEntry") S1 ON S0."SO_TE" = S1."DN_DE"
LEFT JOIN OINV S2 ON S1."DN_TE" = S2."DocEntry"