BAdI Part 8: Implementation Design — Keep BAdI Logic Clean
Preview · a free account unlocks the full lesson
Design BAdI implementations that stay maintainable: thin implementing classes delegating to service classes, clear responsibilities per method, message handling, no UI and no COMMIT, testability with ABAP Unit, and naming/documentation standards.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Parts 1 through 7 covered the mechanics of implementing BAdIs. This lesson is about code quality inside those implementations — the thing that separates maintainable extension code from the most common maintenance problem in enhancement code: a 600-line BAdI method with SELECTs, rules and messages all mixed together.
The core idea is to treat the implementing class as an adapter: it reads what it needs from the BAdI's parameters and objects, maps that into a simple structure, calls out to your own service class — something like ZCL_…_RULES=>check( ) — and then maps the results back into whatever form the BAdI expects, whether that's CH_FAILED, an exception, a message, or a CHANGING parameter. The implementing class is an adapter: it translates BAdI parameters into calls to your own service classes.
This naturally separates responsibilities. Data access belongs in DAO classes, which can also handle buffering, as covered in Part 9. Business rules belong in rule classes that have no dependency on the BAdI interface at all. Business rules live in reusable, unit-tested classes — the same rule can then serve a report, OData service or another BAdI. Message conversion deserves its own single place too. Keeping these separate is what makes the rules themselves unit-testable without needing to start ME21N or VA01 just to exercise them.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Interview questions on this topic
Related SAP topics
Referenced SAP objects
Reviewed reference pages for the objects this page mentions.
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.