In the projects, there are often requirements to post legal and group valuation views in the manual accounting journal entries. If the SAP material ledger parallel valuation solution is in place, tracking the legal and group valuation across all product-related transactions becomes very important. During SAP implementation, this requirement also appears if the company codes or plants are being deployed in a phased manner and if they do transact within themselves. In all of these cases, custom programs are designed to meet the business need. Standard SAP, “BAPI_ACC_DOCUMENT_POST” comes in handy for these scenarios to track and post multiple valuation-based accounting postings. This blog will share a few design elements to use this BAPI to post parallel valuation-based accounting documents.
Figure 1 shows the BAPI_ACC_DOCUMENT_POST with the key tables that are used to post an accounting document. One additional table will be the ACCOUNTTAX table. It’s a bit tricky to map but will be described at the end. The DOCUMENTHEADER table will carry all the information that is relevant to the whole accounting document.
Figure 1: BAPI segments to map intercompany (include accounttax not shown)
Under the ACCOUNTGL segment, along with the regular GL accounts, the Inter-company markup account or valuation clearing defined in T code 8KEN should be included. Figure 2 shows the GL accounts used. The IC MARGIN GL account is from the 8KEN configuration. This segment would need all the key coding fields that need to be mapped to an accounting GL line item such as profit center, partner profit center, plant, quantity, unit of measure, and trading partner. Typically trading partner is not mapped as it will get mapped from the accounts receivable or payable segment business partner.
Figure 2: ACCOUNTGL segment
Figure 3 depicts the account payable table. Typically, this is used when the resulting accounting document is an intercompany payable document. The vendor number is the business partner and usually, this is a special Intercompany type vendor. A trading partner is mapped to the control data of this business partner.
If the GL accounts used in the ACCOUNTGL segment are tax-relevant, these would need to have a tax code mapped.
Figure 3: ACCOUNTPAYABLE segment
The CURRENCYAMOUNT segment would need to have parallel valuation amounts. Ideally, all the currency types would need to be filled. Figure 4 shows that the currency types 00 and 31 have been mapped. Other currency types don’t need to be explicitly defined and mapped here. The system would take of these using the default conversion rule.
Figure 4: CURRENCYAMOUNT segment details
As described earlier, for tax-relevant accounting documents, along with the tax code, all detailed tax lines would need to be mapped in the BAPI. These tax lines are something either the SAP system or any bolt-on application such as VERTEX or ONESOURCE etc. will define. Based on my experience two function modules provide great support around this design. Figure 5 shows the “calculate tax from net amount”. If the taxability is based on the net amount, this can be used to determine the detailed tax lines along with all the attributes that the BAPI needs.
Figure 5: Function module for tax line items
Figure 6 shows a typical results table from this function module. If the line-by-line tax is active in the system, then this results table will show all the details. Each of the results lines will be mapped as a separate line in the ACCOUNTTAX table shown under Figure 8.
Figure 6: Tax function module call details
The external tax call function module shown in Figure 7 can be used to check the total tax calculated by the external tax engine. Based on the results from this function module, the tax amount shown in Figure 6 tax results table should be overwritten in terms of the tax amounts.
Figure 7: RFC tax function module to call the external tax application
Figure 8 shows the ACCOUNTTAX table. Two design elements would need to be considered here. The itemno_acc is an incremental ACCOUNTGL item number. This means that based on the ACCOUNTGL table, for each tax-relevant GL account, multiple tax lines can be generated based on Figures 6 and 7 and each of those lines are numbered with an increment to the account GL table. So, if account GL item number 2 is tax-relevant and based on tax function modules, there are two additional tax lines for this GL, these additional tax lines would be numbered 3 and 4. Then the next line of the ACCOUNTGL table will be numbered as 5 (in this example the valuation clearing GL account). This blog however has been written without considering the second item number GL account being taxable.
The ITEMNO field is a “separate” unique identifier number sequence that joins the ACCOUNTGL table with the ACCOUNTTAX table. Continuing our example if the ACCOUNTGL item number 2 is tax relevant, then it will get an ITEMNO as 00001 and this same number will be mapped to the ACCOUNTTAX table to show that these additional tax lines are for the GL item number 2.
Figure 8: ACCOUNTTAX segment mapping
The valuation clearing GL account items under the ACCOUNTGL table will need to be “last” GL lines. Typically, there are two ways to map the valuation clearing GL lines. One approach would be a summary GL line item for all the ACCOUNT GL items. For example, if the ACCOUNTGL has two GL accounts as there are two materials and other coding block unique fields, then we can map two valuation clearing GL line items showing the intercompany profit per material or we can have one summary intercompany total margin.
Figure 9 shows an example of an accounting document with legal and group valuation-based amounts posted.
Figure 9: A sample accounting document posted by BAPI
This blog captured various nuances around the BAPI accounting document post in the areas of SAP parallel valuation.