加入 EKKO、EKPO 和 EKBE – SAP

huangapple go评论120阅读模式
英文:

Join EKKO, EKPO and EKBE - SAP

问题

EKKOEKPOEKBE 表之间的正确连接逻辑是什么?

我需要获取所有在采购订单上完成的收货单。以下是我当前使用的逻辑:

select "所需列"
from EKKO
inner join EKPO on EKKO.EBELN = EKPO.EBELN
left join EKBE on EKPO.EBELN = EKBE.EBELN and EKPO.EBELP = EKBE.EBELP
where EKBE.BEWTP = 'E'
英文:

What is the correct joining logic between EKKO, EKPO and EKBE tables ?

I need to get all the Good Receipts done on a Purchasing Order. Below is the logic I use currently:

select "required columns"
from EKKO 
inner join EKPO on EKKO.EBELN = EKPO.EBELN
left join EKBE on EKPO.EBELN = EKBE.EBELN and EKPO.EBELP = EKBE.EBELP
where EKBE.BEWTP = 'E'

答案1

得分: 2

EKKO - 采购文档 。<br/>
用于采购文档的头(主)表 - 每个采购文档有一个条目。

关键字段
EBELN 采购文档编号

EKPO - 采购文档 项目<br/>
采购文档的项目表 - 一个采购文档可以有多个条目。

关键字段
EBELN 采购文档编号
EBELP 采购文档的项目编号

EKBE - 每个采购文档的历史记录<br/>
历史记录表 - 每个采购文档项目可以有多个条目。

关键字段
EBELN 采购文档编号
EBELP 采购文档的项目编号
..... 其他字段的数量

这取决于您想要读取的确切数据。由于 EKKOEKPO 的连接是1 - N关系表的连接(对于 EKPOEKBE 表也是如此),从基数较小的表中选择的数据将在结果集中重复出现(在这种情况下,例如,来自 EKKO 的“所需列”对于结果集中的每一行都将是相同的,而来自 EKPO 的列对于每个文档位置的结果集中的每一行也将是相同的)。

如果您不需要从 EKKO / EKPO 表中选择其他数据,您还可以直接从 EKBE 表中选择采购文档的所有货物收货条目:

    SELECT fields_you_need FROM ekbe INTO TABLE @DATA(lt_ekbe)
      WHERE bewtp = &#39;E&#39;
      AND   ebeln = &#39;XXXXXXXXXX&#39;
英文:

EKKO - Purchasing Document Header.<br/>
Header (main) table for the purchasing document - one entry for each purchasing document.

Key field
EBELN Purchasing Document Number

EKPO - Purchasing Document Item<br/>
Items table of the purchasing document - many entries for one purchasing document are possible.

Key field
EBELN Purchasing Document Number
EBELP Item Number of Purchasing Document

EKBE - History per Purchasing Document<br/>
History table - many entries for each of the purchasing document items are possible.

Key field
EBELN Purchasing Document Number
EBELP Item Number of Purchasing Document
..... Number of other fields

It depends on what data exactly you want to read. As join of EKKO and EKPO is the join of 1 - N relation tables (and it is also true for the EKPO and EKBE tables), the data selected from the tables with less cardinality would be duplicated in the result set (in this case, for example, "required columns" from EKKO would be the same for every line in the result set, and from EKPO for every line in the result set per document position).

You can also just select all goods receipts entries for the purchasing document from EKBE table without joins if you do not need to select additional data from EKKO / EKPO tables:

    SELECT fields_you_need FROM ekbe INTO TABLE @DATA(lt_ekbe)
      WHERE bewtp = &#39;E&#39;
      AND   ebeln = &#39;XXXXXXXXXX&#39;

huangapple
  • 本文由 发表于 2023年7月27日 19:20:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76779232.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定