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. ?
First take Table MKPF field MBLNR.
Go to BKPF table and search search key AWKEY this id nothing but Material document number.in same table u can find Accounting number BELNR.
table BSEG in this table u can find Purchasing document or BSET.
Pls give me points if this is usefull.
You are right. But we want to got BKPG/BSEG with the accounting document number. Because material document number/PO doc. number are not a key fields in these fields. Getting accounting document number through material doc. number would take lottt of time, since this field is not a key field.
If you know to find accounting doc number in anyother way, please let us know
PO no --> Material document : Table EKBE (Purchase order history)
Material document --> Accounting document : Table BKPF (Accounting Document Header) here you need to apply logic Doc type = WE (Goods Receipt), Ref. procedure = MKPF (Mat doc header table)
In BKPF table the object key will be the material document number + YEAR.
Hope this helps.
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.