Why do teams move RAP logic out of the handler and saver classes into auxiliary classes, and how do you do it correctly?
Say your answer out loud first.
Practise another way
Behavior pools grow fast: every validation, determination and action lands in one local types include, which is hard to reuse, test and work on in parallel. I move shared logic into an ABP auxiliary class, declared in the BDEF header with auxiliary class.
Unlike an ordinary helper class it gets enhanced access to the business object, so it can use EML IN LOCAL MODE. The handler methods stay thin and just delegate.
Why it matters
- All handler and saver classes of a behavior pool live in its local types include (CCIMP). With 20 validations and actions it becomes one long file that only one developer can edit at a time.
- The same logic (recalculate a total, derive a status) is needed in a determination, an action and the save. Copying it creates bugs.
- Small, typed methods are easier to read and test.
The RAP way: ABP auxiliary classes
managed implementation in class zbp_r_travel unique;
strict ( 2 );
auxiliary class zcl_travel_pricing;
- Declared in the BDEF header; several classes can be listed, comma-separated.
- They provide reusable methods for the behavior implementation and get enhanced access rights to the BO, so EML with
IN LOCAL MODEis allowed. An ordinary global class cannot useIN LOCAL MODEon your BO.
CLASS zcl_travel_pricing DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
CLASS-METHODS recalc_totals
IMPORTING travel_keys TYPE TABLE FOR READ IMPORT zr_travel.
ENDCLASS.
CLASS zcl_travel_pricing IMPLEMENTATION.
METHOD recalc_totals.
READ ENTITIES OF zr_travel IN LOCAL MODE
ENTITY Travel BY \_Booking FIELDS ( FlightPrice CurrencyCode )
WITH CORRESPONDING #( travel_keys )
RESULT DATA(bookings) LINK DATA(links).
" sum per travel, then MODIFY ENTITIES ... IN LOCAL MODE UPDATE FIELDS ( TotalPrice )
ENDMETHOD.
ENDCLASS.
Rules that still apply. The auxiliary class runs inside the RAP transaction, so the phase rules of the caller apply: no COMMIT WORK, no database writes outside the late save phase, no dialog statements. Type parameters with BDEF derived types, not table rows.
Alternatives and when to use them
- Internal action (
internal action reCalcTotalPrice;): callable only from inside the BO withIN LOCAL MODE. Good when the logic is a BO operation in its own right; SAP's Flight reference scenario uses one for price recalculation. - Behavior pool per entity:
implementation in class ... uniqueon eachdefine behavior forsplits handlers by entity. - Plain classes for pure calculations with no EML at all; they are the easiest to unit test.
Senior point: keep handler methods as orchestration (read, delegate, write failed/reported) and put rules in classes. It also makes later extension and code review far easier.
Explains the maintainability problem, the auxiliary class declaration and its IN LOCAL MODE privilege, and compares it with internal actions and per-entity pools.
Creates an ordinary helper class, then cannot explain why IN LOCAL MODE fails there, or moves COMMIT logic into the helper.
Treating the auxiliary class as outside the RAP transaction and calling COMMIT WORK or writing to the database from it during the interaction phase.
- What is the difference between an auxiliary class and an internal action?
- Why can an ordinary class not use IN LOCAL MODE on your BO?
- How would you unit test logic that sits in an auxiliary class?
3 official pages and 1 prep guide. Confidence: high. Checked 1 Dec 2026.
- Prep guide Gives the question.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.