This blog post aims to provide a lesser known, but a very powerful tool to fetch the follow on document numbers from a given document number while writing custom ABAP based reports.
For example, a report is to be submitted to external authorities/auditors/internal management giving the extract of the SD billing document, FI document posted, and other details related to currency, amount. To further add to the complicacy, assume this is to be submitted for some specific customers or product groups. Developing such a report would involve fetching the data from various tables like VBRK, BKPF, BSEG, etc which may lead to long run times
Another case is FI/COPA reconciliation where it is often reconciled what is posted in FI and what not posted in COPA to arrive at the “reconciliation items”.
Standard SAP offers a function module BAPI_ACC_DOCUMENTS_RECORD which can simplify the process of data extraction. Lets see it using 3 different cases
Case 1 – Identify the follow on documents (CO/PCA/COPA,etc) from FI document
Go to SE37 and enter the FM BAPI_ACC_DOCUMENTS_RECORD. Press F8 to test the same
Click on against the External_Documents and enter the following details
OBJ_TYP = BKPF (BKPF identifies that the origin of the transaction lies in FI )
OBJ_KEY = FI Document Number + Company + Fiscal year
OBJ_SYS as “System ID_Client No”. The system ID can be obtained from SAP Log on Pad
Press F3 (back) after you have entered above details. Following screen appears
Press Execute (F8). The “Result” under “Accounting_Documents” shows 18 entries
Click on against the Accounting_Documents and you can see the following 4 types of documents
In Column REC_T,
BKPF – Stands for FI Doc
COPCA – Stands for PCA Doc
COBK – Stands for Controlling document
COPA – Stands for COPA document
Case 2: Identify the follow on Accounting documents (FI/CO/PCA/, etc ) from MM documents
Go to SE37 and enter the FM BAPI_ACC_DOCUMENTS_RECORD. Press F8 to test the same
Click on against the External_Documents and enter the following details
OBJ_TYP = MKPF (MKPF identifies that the origin of the transaction is in MM)
OBJ_KEY = MM Document Number + Fiscal year
OBJ_SYS as “System ID_Client No”. (The system ID can be obtained from SAP Log on Pad)
Press F3 (back) after you have entered above details. Following screen appears
Press Execute (F8). The “Result” under “Accounting_Documents” shows 4 entries
Click on against the “Accounting_Documents- Results” and you can see the following 4 documents
In Column REC_T
BKPF – Stands for FI Doc
COPCA – Stands for PCA Doc
GLX – Stands for Special Purpose Ledger
COBK – Stands for Controlling document
Case 3: Identify the follow on Accounting documents (FI/CO/PCA/COPA/SPL, etc) from external documents (SD)
Follow the same process as above with following details
OBJ_TYP = VBRK and
OBJ_KEY = SD Billing document No. (Without suffixing any Fiscal year and Company code)
OBJ_SYS = System ID_Client No