Populate the Profit Center Using a BAdI for Tax Lines

  • by Charles Liu, SAP Manager, Luxottica Retail Co. Ltd.
  • August 29, 2014
Learn how to use a Business Add-In (BAdI) to populate the profit center for the tax lines when you use BAPI_ACC_DOCUMENT_POST to post a document. Follow step-by-step instructions to use the BAPI and BAdI with the sample code. In this way, you can extend the BAPI functionality and easily populate the profit center by yourself.
Learning Objectives

By reading this article you will learn:

  • The concept of document splitting characteristic in the SAP General Ledger
  • How to populate the profit center during BAPI BAPI_ACC_DOCUMENT_POST posting
  • How to implement the method CHANGE in the Business Add-In (BAdI) to populate the profit center for the tax lines
Key Concept
BAPI BAPI_ACC_DOCUMENT_POST is the BAPI function module widely used for posting of FI documents. It has a function similar to transaction FB01.

You may face a situation in which a business user wants to allocate e-commerce sales/cost of goods sold (COGS) to a retail store based on some rules such as the nearest store or by address. The solution is to post the sales revenue /COGS to the profit center that links to the target store. As the profit center is a mandatory field and is required to be zero-balanced in the SAP system, you have to ensure that profit centers are populated for each line item of the document.

If you implement this requirement, your first inclination maybe to use BAPI BAPI_ACC_DOCUMENT_POST to create the financial accounting document. However, I recommend that you to extend its functionality with a BAdI. However, the issue is that the profit center can’t be populated for two tax line items. At first glance, you can use substitution, transaction code OKB9, or even a manual input to meet the requirements. However, on closer consideration you can see those won’t work. OKB9 only provides the default cost center/profit center, but the profit center in my example is variable. Substitution doesn’t work for the same reason. Document splitting also doesn’t work as the document splitting rule is not so advanced that it can populate the profit center for two tax lines.

Fortunately you can use a Business Add-In (BAdI) to change table C_ACCIT, which includes the tax lines. The solution is to implement the BAdI, populate the profit center for the two tax line items, and post the document. The BAPI provides structure EXTENSION2, which can be retrieved in the BADI AC_DOCUMENT. I explain how to implement the BAdI to populate the profit center and then provide sample code to demonstrate it.

A Business Case

The business requires allocation of sales revenue or COGS to the profit center based on some rules. The profit center is a mandatory field and is required to be zero balanced in the SAP system. Document splitting is also activated so that the profit centers in the BAPI have to be populated. 

As a result of integration of Profit Center Accounting (PCA) into the SAP General Ledger, new functions such as document splitting are available. Using the document splitting function (online document split), you can create balance sheets for company codes as well as for other entities such as the profit center. The balance is then set to zero for each document for the profit center.

To check the document splitting characteristic for general ledger accounting, follow IMG menu path Financial Accounting (New) > General Ledger Accounting (New) > Business Transactions > Document Splitting > Define Document Splitting Characteristics for General Ledger Accounting. In the screen that appears (Figure 1), you can specify a mandatory field after document splitting. In my example, I have specified the partner field named PRCTR and entered a description (e.g., PRCTR Profit Center). I also selected the indicators for Zero balance and Mandatory Field. Because the Mandatory Field indicator is set, all postings in which no value is set for the specified field after document splitting are rejected with an error message.

Figure 1
Set up a mandatory field after document splitting

Because the profit center is configured to be a mandatory field and is a document splitting characteristic, you have to feed the profit center to the BAPI BAPI_ACC_DOCUMENT_POST. 

SAP has provided many BAPIs to post an accounting document, including BAPI_ACC_GL_POSTING_POST, BAPI_ACC_DOCUMENT_POST, and BAPI_ACC_BILLING_POST. I only discuss BAPI BAPI_ACC_DOCUMENT_POST in this article as I chose to calculate the tax by myself to feed the BAPI under this business scenario.

Charles Liu

Charles Liu is SAP manager at Luxottica Retail Co. Ltd. with 15 years consulting and industry experience. He has experience in FI and CO along with ABAP programming. He has a degree in computer science from Jiangxi Normal University and a master’s degree in information and systems from Fudan University.

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.