英文:
Join EKKO, EKPO and EKBE - SAP
问题
EKKO
、EKPO
和 EKBE
表之间的正确连接逻辑是什么?
我需要获取所有在采购订单上完成的收货单。以下是我当前使用的逻辑:
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 | 采购文档的项目编号 |
..... | 其他字段的数量 |
这取决于您想要读取的确切数据。由于 EKKO
和 EKPO
的连接是1 - N关系表的连接(对于 EKPO
和 EKBE
表也是如此),从基数较小的表中选择的数据将在结果集中重复出现(在这种情况下,例如,来自 EKKO 的“所需列”对于结果集中的每一行都将是相同的,而来自 EKPO 的列对于每个文档位置的结果集中的每一行也将是相同的)。
如果您不需要从 EKKO / EKPO 表中选择其他数据,您还可以直接从 EKBE
表中选择采购文档的所有货物收货条目:
SELECT fields_you_need FROM ekbe INTO TABLE @DATA(lt_ekbe)
WHERE bewtp = 'E'
AND ebeln = 'XXXXXXXXXX'
英文:
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 = 'E'
AND ebeln = 'XXXXXXXXXX'
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论