Link to find Accounting document number from Material document number / PO
We are working on a custom report, in which we need to print purchasing details (from EKPO, EKKO & EKBE) as well as accounting details (from BSEG & BKPF). We need to hit BKPF/BSEG with the accounting document number, since it is the only key field (though PO number is there in BKPF, we can not use this because it is not a key field)
My question from which table we get the accounting document number ? We need to provide a link between purchasing & accounting through accounting document number, but how to find the accounting document number. ?
Venkatachalam Renganathan replied
I guess you are trying to fetch Accouting Documents for goods receipt against PO.
To do this, you need to look at the PO History table (EKBE) and find out the Corresponding material document (VGABE = 1 for good receipt).
Get the value of BELNR and GJAHR.
Concatenate BELNR and GJAHR into your refernce key (like BKPF-AWKEY).
Then use this key to read table BKPF with the following key
AWTYP = 'MKPF' for Material document
AWKEY = reference key generated above.
AWSYS = the value of the logical system (if used) or blanks
This will get you quicker access as compared to what you've described below. In this case, the system uses a standard SAP Index "Index by application type and key" to fetch the relevant records.
Hope this helps.