SAP BAdI extension: card transactions as single posting lines
One accounting team needed every corporate card transaction as its own posting line, while the standard integration condensed them for every company. I built a small extension on the SAP side that keeps them separate for that team’s companies only.
- Role
- Analysis, design and build
- Status
- In production after written test confirmation
- Limits
- Users reported the problem; the change is a few lines
An anonymized case from my consulting work. Customer, product names, countries, the number of companies, ticket details and verbatim feedback are left out.
Reconciliation: condensed vs. single posting lines
Corporate card statement
- Hotel, two nights 389.00 no line line E-01
- Train ticket 96.40 no line line E-02
- Taxi to the airport 38.50 no line line E-03
- Dinner with the team 88.50 no line line E-04
Posting lines in SAP
- Card, report R-1042, 4 items 612.40
- Card, report R-1042, E-01 389.00
- Card, report R-1042, E-02 96.40
- Card, report R-1042, E-03 38.50
- Card, report R-1042, E-04 88.50
0 of 4 card transactions find a posting line. Each one has to be traced by hand through the expense report. 4 of 4 card transactions find their posting line by amount and reference.
Background: SAP standard and BAdIs
SAP ships a large standard: programs and tables that SAP maintains and updates. Customers adapt it through settings, and where settings stop, SAP offers defined extension points. A BAdI (Business Add-In) is one of them: an interface inside the standard code that calls customer code at a fixed moment, much like a plugin hook in web software. Code in a BAdI survives upgrades. A change to the standard code itself, called a modification, has to be checked and often redone after every upgrade, so most customers rule it out.
The integration in this case is part of that standard. The expense tool exports approved reports as files. On the SAP side, a standard interface reads them and posts them as accounting documents. Country differences are handled in control tables: which document types are processed per country, exceptions per company, which finance modules are active. Along the way, the interface offers several BAdIs.
Problem: condensing for all companies
The integration condenses card lines from the same expense report into one posting line. The standard setting controls condensing by line type, but it applies to every company.
For most of the customer’s companies, that was fine. One accounting team reconciles every card transaction on its own, and one condensed line per report turned that into manual work. They asked for individual lines for their companies only. No setting could do that, and changing SAP standard code wasn’t an option.
Options considered
- A setting
- Condensing can be switched per line type, but only for all companies at once. There is no entry per company.
- The expense tool
- The vendor confirmed in a support ticket that it could not limit condensing to some companies either.
- A modification
- Changing the standard program would have worked, but it would need checking after every upgrade. Not an option for this customer.
- A BAdI
- What I did: a supported extension point that runs before condensing and knows the company.
Solution: BAdI before condensing
Condensing combines lines only when certain key fields match. One of them is the line text. Of the BAdIs along the interface, one lets me set that text, and it runs before condensing, while the line still carries the company it belongs to.
For card lines of the affected companies, the extension writes a reference back to the source system into that field. Every card transaction then differs from the others and stays on its own line. Other companies and cash expenses never go through the extension. Most of the work was proving that the extension point runs early enough and still has the data it needs.
Posting flow and extension point
- Expense tool Approved reports are exported as files.
- SAP standard Interface reads the file Control tables decide per country which document types are processed.
- my code BAdI: line text Runs before condensing and still knows the company. For card lines of the affected companies, it writes a source reference into the text.
- SAP standard Condensing Lines are combined when their key fields match. The line text is one of them.
- SAP standard Accounting document Posted in SAP finance. Card lines now stay separate; cash lines are still condensed.
Result
The accountants now see one line per card transaction, and the text field, which held nothing useful before, shows a reference they can trace back to the source. Cash expenses are still condensed.
The users had reported the problem before I started. The change itself is a few lines of code; most of the effort went into proving that it works. The accounting team confirmed the result in the test system in writing, and then it went to production.