Tips and Tricks for Using BAPIs in Accounting Documents

  • by Sergey Korolev, Independent ABAP Consultant
  • February 8, 2010
Posting accounting documents with BAPIs can be somewhat tricky — generating a simple accounting document turns into a report with several hundred lines of code. Accounting functionality is highly dependent on company specifics and legislation, so to make your program more stable against accounting business changes, you have to be able to derive automatically as many customizing parameters as possible. Here are some methods to make the task simpler. Included are three sample programs to help you understand the best way to use BAPIs when posting accounting documents.
Key Concept
Simply stated, a BAPI is nothing more than a function module that has the following features: 
  • It is Remote Function Call-enabled so you can call it remotely (e.g., via a Web service)
  • It has a stable interface. Once released for general use, all names and types of its parameters remain the same even in newer versions of the SAP system.

A common development task found in every SAP core implementation project is the posting of accounting documents programmatically. Although the most popular technique to accomplish this task is batch input, sometimes it is better to use BAPIs. For example, suppose you need to implement a transactional model creating documents or even a chain of different documents in one database Logical Unit of Work (LUW) with an all-or-nothing paradigm. In that case, you cannot use batch input because once the document is created, it cannot be easily rolled back.

With accounting documents, BAPI function modules are somewhat tricky. The existing documentation is very sparse and the data structure of BAPI parameters looks slightly different from what you can expect compared to well-known accounting document tables. Using BAPI function modules can be difficult if you have to create more complicated documents, such as those with tax calculations or Accounts Receivable/Accounts Payable (AR/AP) items having special general ledger (GL) indicators.

I will walk through the accounting BAPI to enable ABAP developers to better understand this Financial Accounting (FI) functionality. I illustrate simple examples of the accounting BAPI and also discuss a tricky topic — dealing with taxes.

Sergey Korolev

Sergey Korolev has been working as an ABAP consultant since 1999. For the past three years, he has worked as a freelancer for different customers including IBM, SAP, and Siemens. His areas of interest are interfacing technologies, object-oriented programming, and business process modeling.

See more by this author


No comments have been submitted on this article. 

Please log in to post a comment.

To learn more about subscription access to premium content, click here.