ERPClimb logoERPClimb

SAP RAP / CDS / OData Behavior Implementations Interview Questions

In SAP RAP / CDS / OData rounds, behavior implementations questions are where configuration knowledge meets day-to-day behaviour — what a setting does, and what breaks in a live system when it is wrong.

Learn how RAP behavior pools implement actions, determinations, validations, authorization and unmanaged persistence while respecting bulk-processing and save-sequence rules. The emphasis is thin framework handlers, reusable domain services and correct FAILED/REPORTED messaging.

This page carries 10 reviewed SAP RAP / CDS / OData behavior implementations interview questions, each with a complete written answer and no sign-in required. The set breaks down into 1 foundational, 7 mid-level and 2 advanced questions, so you can start at the top for a first interview or skip ahead to the scenario-based items for a senior round.

Rehearse these out loud rather than reading them. If you can explain each answer in your own words, including one realistic way it goes wrong on a project, you are covering what a normal SAP RAP / CDS / OData round on behavior implementations expects.

10 Behavior Implementations questions with answers

easyBehavior Implementations

1. What is a behavior pool, and what is the difference between its handler and saver classes?

The behavior pool is a global class (e.g. ZBP_R_PURCHREQ, "ABSTRACT FINAL FOR BEHAVIOR OF zr_purchreq") whose code lives in local classes in the local types include. Handler classes (INHERITING FROM cl_abap_behavior_handler, usually one per entity) contain interaction-phase methods: determinations, validations, actions, functions, authorization, feature control, prechecks, and in unmanaged BOs create/update/delete/read/lock. The saver class (INHERITING FROM cl_abap_behavior_saver) contains save-sequence methods: finalize, check_before_save, cleanup_finalize, adjust_numbers, save/save_modified, cleanup — needed only for unmanaged BOs, late numbering or additional/unmanaged save. Methods are generated from the BDEF with the ADT quick fix and called by RAP, never by you.
mediumBehavior Implementations

2. Explain %tky, %key, %cid, %pid, %control and %param. Which mistake happens when developers use key fields instead of %tky?

%tky: transactional key = key plus %is_draft; identifies draft or active instance. %key: key fields only. %cid: content ID for a new instance within one request. %pid: preliminary ID with late numbering. %control: which fields were supplied (mk-on per field), essential for partial updates. %param: action parameter input or action result. Using key fields (or %key) instead of %tky works until draft is enabled — then handlers read or modify the active instance instead of the draft, so determinations appear not to work and data ends up wrong. Using %tky from the start makes code draft-safe.
mediumBehavior Implementations

3. A purchase request total is sometimes doubled after editing in draft. The determination adds the changed item's amount to the total. What is wrong and how do you fix it?

The determination is not idempotent. RAP may run it several times in one transaction (item change, Prepare, activation), and each run adds the amount again. Fix: recompute instead of accumulate — read all items of the affected requests (READ ENTITIES … BY \_Item IN LOCAL MODE) and set TotalAmount to their sum per request in one MODIFY. Keep triggers narrow (create and field Quantity, Price on the item), handle deletions (recalculate on the parent or trigger on delete where supported), and add a test that runs the change twice and compares totals.
mediumBehavior Implementations

4. What rules must determinations and validations follow, and what must they never do?

Determinations: idempotent (recompute, skip already-correct instances), set-based READ/MODIFY IN LOCAL MODE, narrow triggers, choose on modify (user must see value) vs on save (persistence-time or one-time values). Validations: only read and report — FAILED plus REPORTED with %element and %state_area (clear first). Never: COMMIT/ROLLBACK, direct DML on BO tables, RFC/HTTP calls, e-mails or other external side effects, changing data in a validation, SELECT per instance in a loop, MESSAGE statements. External effects belong in the save phase or after commit.
mediumBehavior Implementations

5. An integration called the approve action for requests in status New and approved them, bypassing the workflow. The Fiori button was correctly disabled. What went wrong?

The rule existed only as UI behavior (or was not declared as feature control), and the action implementation trusted that only valid instances arrive. Any API can call any action. Fix: declare the action with ( features : instance ) and return disabled in get_instance_features unless status is Submitted — RAP then rejects calls in the wrong state for every channel. Add business checks not expressible as feature control (e.g. amount limit) inside the action, reported per instance with a message class. Add tests that call the action via EML in each status.
mediumBehavior Implementations

6. Implement a 'copy request' feature in RAP. Which action type do you use and how does it return the new instance?

Use a factory action: "factory action copyRequest [1];". Each key in the implementation carries a %cid supplied by the caller. Read the source instances (IN LOCAL MODE), then MODIFY ENTITIES … CREATE with %cid = key-%cid and the copied field values; copy children in the same MODIFY with CREATE BY \_Item and %cid_ref to the new root's %cid. Pass the resulting MAPPED to the action's mapped parameter so the caller receives the new keys. Reset fields that must not be copied (status, numbers, admin fields — they are set by determinations). Fiori shows the new instance (as a draft if draft-enabled).
mediumBehavior Implementations

7. An audit log written in a determination contains duplicate entries and entries for changes that were never saved. How do you fix it?

Determinations run in the interaction phase, possibly several times, and also for changes that later fail validation or are discarded — so the log is written too often and too early. Move the log to the save phase: declare "with additional save" (managed) and write log rows in save_modified from create/update/delete. save_modified runs once per successful save, after all validations passed, in the same LUW as the business data — so log entries exist exactly when the change is persisted. Remove the log code from the determination and test both a failed and a successful save.
mediumBehavior Implementations

8. How do you test and debug a RAP behavior implementation effectively?

Testing: EML-based ABAP Unit tests — MODIFY/EXECUTE, COMMIT ENTITIES RESPONSE when save-phase rules matter, assertions on FAILED/REPORTED/READ results, ROLLBACK ENTITIES in teardown; SQL test doubles (cl_osql_test_environment) for isolation; tests for every validation, determination (idempotency), action, feature control, draft and a bulk case; run in ATC/CI. Debugging: normal breakpoints for EML tests; external (user) breakpoints for Fiori/API requests; ABAP Cross Trace to see which RAP operations, determinations and validations ran; /IWFND/ERROR_LOG, /IWBEP/ERROR_LOG and ST22 for failures; ST05 and the profiler for performance.
hardBehavior Implementations

9. When does a managed RAP BO need a saver class, and what goes into adjust_numbers and save_modified?

A plain managed BO needs none: on-save determinations and validations are handler methods, the framework writes tables. A saver is needed for: • Late numbering — adjust_numbers: mapped contains the new instances (identified by %pid); assign final key values (e.g. from a number range), drawn as late as possible so failed saves use no numbers. • Additional save — save_modified: framework writes the BO tables; you add work in the same LUW (change log, outbox). • Unmanaged save — save_modified: framework does not write; translate create/update/delete (with %control, or full data) into the persistence API. Save-phase rules: no failures, no commits, no EML MODIFY.
hardBehavior Implementations

10. You review an inherited behavior pool before go-live. What checklist do you apply?

1. Structure: one handler per entity, saver only where needed, reusable logic extracted. 2. Every method processes all keys; no keys[ 1 ]. 3. %tky everywhere; READ/MODIFY IN LOCAL MODE for the own BO. 4. No COMMIT/ROLLBACK, no direct DML on BO tables, no external calls in determinations/validations, no MESSAGE statements. 5. Determinations idempotent with narrow triggers; validations only report, with %element and %state_area. 6. No SELECT in loops; FOR ALL ENTRIES guarded. 7. Every FAILED has a REPORTED message from a message class. 8. Authorization in authorization methods, state rules in feature control. 9. Tests exist for each rule plus bulk and draft; they run in ATC. Blocking: commits, missing authorization, per-key DB access in mass operations, untested validations.

Related lesson

Behavior Implementations Part 4: Save Sequence, Late Numbering and Unmanaged Save

Related topics

Next practice step

Go deeper on this topic