In the previous two posts, I discussed the BAPI concept for posting clearing postings and simulating the accounting entries. Today, I will give you a brief tutorial on how to use the BAPI to post an accounting entry in SAP. BAPI_ACC_DOCUMENT_POST allows you to post any kind of accounting entry, i.e., GL postings, Customer or Vendor postings, etc.
The only drawback of this BAPI is that it does not post clearing transactions. So, if you want to post an accounting entry and simultaneously do the clearing as well, then you should check out my tutorial on POSTING_INTERFACE_CLEARING BAPI.
Today, I will show you a scenario where I will post an accounting document with a total of 3 line items. 2 GL line items, One balance sheet, and one expense, and 1 customer line item. In this BAPI, there are separate tables for each type of posting. For example, if you want to post only to a GL Account, then there is one table that you need to populate. Similarly, to post customer or vendor postings, there are separate tables.
Unlike POSTING_INTERFACE_CLEARING that is used for the FB05 transaction code, please note that the BAPI_ACC_DOCUMENT_POST is the same as transaction code FB01 or F-02. As you already know that FB01 allows you to post accounting documents without clearing.
Table of Contents
Step 1: Execute the BAPI_ACC_DOCUMENT_POST in SE37
To display the BAPI structure & tables, you need to execute it in t-code SE37. Enter the BAPI name BAPI_ACC_DOCUMENT_POST in the function module field and click on the ‘Execute‘ button given at the top in the navigation section.
After you execute the BAPI, you will notice two sections namely Import Parameters & Tables. Under Import Parameters, you need to specify the accounting document header details like Document Date, Posting Date, Company Code, Reference, Header Text, etc. Since these header details remain the same for the whole accounting document, hence it is to be filled at the header level.
For all the line items, this BAPI has multiple tables. For example, ACCOUNTGL, ACCOUNTRECEIVABLE, & ACCOUNTPAYABLE tables are used for entering the GL accounts, Customer Codes, & Vendor Codes respectively.
There are other tables like ACCOUNTTAX & CRITERIA that can be used to enter tax & COPA-related details respectively.
Step 2: Fill the Header Details in the DOCUMENTHEADER section
As a first step, you need to enter the accounting document header details. In the screenshot below, I have entered all the required fields like Header Text, Username, Document & Posting Date, Company Code, Document Type, & Reference.
Step 3: Fill the GL Account Details in the ACCOUNTGL Table
As I mentioned earlier, I’m showing a scenario where I am going to post 3 line items (2 for GL Accounts & 1 for Customer). Basically, I’m going to post the following accounting entry:
|Balance Sheet GL a/c||Cr.||100-|
|Expense GL a/c||Dr.||40|
Since I have 2 GL line items, I need to enter both the GL account details in the ACCOUNTGL table. Starting with the Balance Sheet GL Account, I have given ITEMNO_ACC as 1, GL Account, Item Text, and Company Code.
Similarly, I will enter the second line item for the expense GL account. In this case, ITEMNO_ACC is 2 and since it’s an expense account, I have also entered a cost center.
Step 4: Fill the Customer Code Details in the ACCOUNTRECEIVABLE Table
Now it’s time to enter the details for the third line item for customer. If you are posting to a customer code, then you need to use this table. The ITEMNO_ACC is 3 now, enter the customer code along with other details like payment terms, item text, etc. You can also make use of other optional fields like payment method, reference key, etc.
Step 5: Enter the Amounts for all the Line Items in the CURRENCYAMOUNT Table
You might have noticed that so far we have only entered the GL account and customer code. We haven’t specified the amounts for each line item and also the debit/credit indicators. In the BAPI, you need to enter the amounts along with currency & debit/credit indicators in the CURRENCYAMOUNT table.
In the screenshot below, for all the line items, the document currency is USD. Also, for line item 1, amount is -$100. The negative sign next to the amount identifies it as a credit amount. Similarly, for the rest of the 2 line items, I have provided a debit amount. As you can see, the credit amount is equal to the debit amount. So, while posting this document, we shouldn’t face any ‘Balances in Transaction Currency’ error.
Step 6: Execute the BAPI & Post the Accounting Document
After entering the details of all the line items, when you go back to the main screen of the BAPI, you would notice that there are entries under each table. For example, there are 2 entries in ACCOUNTGL table. It means this table has 2 GL line items. A 1 entry in ACCOUNTRECEIVABLE table means there is 1 customer line item.
Similarly, 3 entries in CURRENCYAMOUNT table means that the amounts have been entered for all the 3 line items. Click on the ‘Execute‘ button to post the accounting document.
After executing the BAPI, you can see the posted accounting document number in the Export Parameters section. For example, the accounting document posted is 0100000025 in company code 1234, and fiscal year 2021.
I hope you have liked this tutorial on the BAPI_ACC_DOCUMENT_POST to post an accounting document. If you have any questions, please feel free to drop a comment or mail at email@example.com. Until next time, Take Care!!!