Financial AccountingMiscellaneous

BAPI_ACC_DOCUMENT_POST: BAPI to Post Accounting Document in SAP

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.

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.

BAPI_ACC_DOCUMENT_POST in SE37
BAPI Name in SE37

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.

BAPI to post accounting document in SAP
BAPI Initial Screen

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.

Enter the details in DOCUMENTHEADER.
Enter the Document Header Details

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:

AccountDebit/Credit IndicatorAmount
Balance Sheet GL a/cCr.100-
Expense GL a/cDr.40
Customer CodeDr.60

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.

Enter GL Line Items BAPI_ACC_DOCUMENT_POST
Enter the GL Line Items

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.

Enter GL Line Items in BAPI_ACC_DOCUMENT_POST
Enter the GL Line Items
BAPI to Post an Accounting Document in SAP
Enter the 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.

Enter the Customer Details in BAPI
Enter the Customer Details

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.

BAPI to Post an accounting document in SAP
Enter the Amounts for all line items

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.

Execute the BAPI_ACC_DOCUMENT_POST
Execute the BAPI

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.

Display the BAPI Results.
Display the Results

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 protected]. Until next time, Take Care!!!

3Shares

One thought on “BAPI_ACC_DOCUMENT_POST: BAPI to Post Accounting Document in SAP

  • Shridhar M Pai

    Hi Sir,
    Could you please reupload the images or give a sample code for this.
    So that we can refer and understand more clearly sir.
    I want to make use of BAPI_ACC_DOCUMENT_POST to File GL Account postings from FB01.

    Thank you
    Regards,
    Shridhar M Pai

Comments are closed.