Hi Isaac,
thank you for your question!
You can connect the table EKPO to BSEG by joining the table
RSEG with the keys MANDT, EBELN, EBELP to EKPO
RSEG with keys MANDT, BELNR, GJAHR to RBKP
RBKP with the keys MANDT, BELNR, GJAHR to BKPF
BKPF with the keys MANDT, BELNR, BUKRS, GJAHR to BSEG
Usually this is also standard to configure in the P2P Data Model in a data connection perspective.
From an analysis perspective, why would you dont like to use the table EKBE to compare them? I would propose to sum up the invoice value in EKBE and pull it to the PO.
PU_SUM(EKPO, EKBE.REEWR)
Best Regards,
Data Science Team
the relation of BSEG to EKKO and EKPO is as follows (all within one MANDT = SAP client)
BSEG-EBELN = EKKO-EBELN = EKPO-EBELN = PO number
BSEG-EBELP = EKPO-EBELP = PO item number
please note that one PO number may be related to many invoice numbers
and one PO item may be related to many invoice items (of different invoices).
Point 3. of the above answer is wrong. RBKP-BELNR is the logistical invoice number, while BKPF-BELNR is the number of the accounting document. They are differnet. The concatenqtion of RBKP-BELNR and RBKP-GJAHR is usually found in BKPF-AWKEY.
Best Regards, Christian Preitschopf