ERPClimb logoERPClimb

SAP RAP / CDS / OData Behavior Definitions Interview Questions

Interviewers use behavior definitions to test depth rather than coverage: the follow-up question is almost always "why does the system behave that way?", and that is where prepared answers usually run out.

Master RAP behavior definitions as the contract for CRUD, field control, actions, determinations, validations, locks, authorization, ETags and feature control. Learn how to make the BO behavior explicit before writing implementation logic.

This page carries 10 reviewed SAP RAP / CDS / OData behavior definitions interview questions, each with a complete written answer and no sign-in required. The set breaks down into 2 foundational, 5 mid-level and 3 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.

If you can handle every question here without hesitating, behavior definitions is unlikely to be what costs you an SAP RAP / CDS / OData interview — and the same reasoning pattern transfers to the neighbouring topics linked at the bottom of this page.

10 Behavior Definitions questions with answers

easyBehavior Definitions

1. What is a behavior definition, and what goes into its header, entity header and entity body?

The behavior definition (BDEF), written in Behavior Definition Language, is the transactional contract of a RAP BO; RAP enforces it before your code runs. Header: implementation type and class (managed/unmanaged … implementation in class … unique), strict ( 2 ), with draft. Entity header (define behavior for … alias …): persistent/draft table, lock master/dependent, authorization master/dependent, etag master, total etag, early/late numbering. Entity body: create/update/delete with options, field characteristics, association operations, determinations, validations, actions, functions, draft actions, side effects and the mapping block. Each logic element becomes a generated method in the behavior pool.
easyBehavior Definitions

2. Why do child entities in a RAP BDEF usually have no create operation of their own, and what must the child declare?

A child cannot exist without its parent. Offering create only via the parent's association ("association _Item { create; }") guarantees every child gets a valid parent key — orphans become impossible without code. EML uses CREATE BY \_Item with %cid_ref or the parent's key. The child declares "association _Request;" (with draft if draft-enabled) in its body, which enables read-by-association to the parent and is needed for "lock dependent by _Request" and "authorization dependent by _Request". Associations to other BOs are not declared in the BDEF.
mediumBehavior Definitions

3. You join a project with an unfamiliar RAP BO. How do you understand what it allows in five minutes, just by reading its BDEF?

1. Header: managed or unmanaged, draft, strict mode. 2. Root entity header: persistence, lock master, authorization master (global/instance), ETag and total ETag, numbering. 3. Operations: which of create/update/delete exist, which are feature-controlled or internal — and which are deliberately missing. 4. Field characteristics: readonly, mandatory, readonly:update, dynamic fields. 5. Business logic: determinations and validations with triggers, actions and their feature/authorization options. 6. Children: lock/authorization dependent, create only via parent association. Then check the projection BDEF to see what each service actually exposes. This gives the contract without reading handler code.
mediumBehavior Definitions

4. Explain field characteristics in a BDEF: readonly, readonly : update, mandatory, mandatory : create and features : instance. When would you use each?

readonly: consumers can never set it — status, totals, admin fields; the BO sets them in local mode. readonly : update: settable on create only, then fixed — an external reference or document type. mandatory: must always be filled — description. mandatory : create: required when creating, e.g. currency, but not re-checked as mandatory later. features : instance: decided at runtime in get_instance_features (fc-f-read_only, fc-f-mandatory, fc-f-unrestricted) — e.g. supplier editable only in status New. Declaring these removes code, RAP rejects invalid requests before handlers run, and Fiori renders fields correctly.
mediumBehavior Definitions

5. Which kinds of actions and functions can you declare in a BDEF? Give a use case for each.

Instance action (approve result [1] $self) — business step on selected instances. Static action — no instance, e.g. create from template. Factory action (copyRequest [1]) — creates new instances, e.g. copy; returns via MAPPED. Static factory action — creates without a source instance. Internal action — only callable inside the BO, e.g. recalculation. Action with parameter (reject parameter ZD_RejectReason) — input via abstract entity; Fiori shows a dialog. Function (getApprovalLevel result [1] ZD_…) — read-only computed result. Options: features : instance, authorization : update, precheck. Results: $self, other entity, cardinalities.
mediumBehavior Definitions

6. Users see outdated totals in a Fiori app after changing item quantities, and someone proposes a 'Recalculate' button. What would you do instead?

First check the determination: it should run on modify with triggers create and field Quantity, Price on the item and recompute the parent's total idempotently. If it already runs, the backend value is correct but Fiori does not know it changed. Declare side effects in the BDEF so Fiori Elements reloads the affected field or entity after the change (e.g. a quantity change affecting the total), then clear the metadata cache and test. A Recalculate button is a workaround that users forget to press and that can be pressed in wrong states. Side effects only tell the UI what to reload; they do not execute logic.
mediumBehavior Definitions

7. After enabling draft, adding an item in the Fiori app fails. The header has 'with draft' and draft tables exist. What do you check?

Run the draft checklist: header with draft; draft table on every entity (regenerated after field changes); total etag on the root; draft actions Edit, Activate, Discard, Resume and Prepare; "with draft" on both association declarations (association _Item { create; with draft; } and association _Request { with draft; }); projection BDEF with use draft, use of all draft actions and with draft on use association; and handler code using %tky rather than keys. In this symptom the missing "with draft" on the association (base or projection) is the most likely cause. Verify $metadata and retest after clearing caches.
hardBehavior Definitions

8. What do 'precheck', 'internal' and 'authorization : none' mean on BDEF operations, and what risks come with them?

precheck: a precheck method runs before the operation reaches the buffer or draft; it rejects obviously invalid input early. Risk: duplicating validation logic — keep prechecks cheap. internal: the operation or action is only callable from inside the BO (IN LOCAL MODE), e.g. recalculation used by other handlers. Risk: none for consumers, but forgetting local mode makes calls fail. authorization : none: the operation is not authorization-checked. Risk: an unprotected operation — use only when truly harmless and document why; strict mode forces this to be explicit rather than accidental. Related: authorization : update lets an action reuse the update authorization.
hardBehavior Definitions

9. What is the difference between a projection BDEF and an interface BDEF, and when do you need each?

Projection BDEF ("projection;" on a transactional_query projection view): selects behavior of the base BO for one service with "use" statements — e.g. the Fiori UI projection with draft and an API projection without draft or delete. Anything not listed is not available to that service. Interface BDEF ("interface;" on a transactional_interface projection, often …TP): a stable, releasable EML API for other developers and BOs, decoupling them from the internal base BO. SAP's released BO interfaces use this pattern; clean-core code calls them via EML. Need a projection for every service; add an interface when other programs or BOs call your BO via EML.
hardBehavior Definitions

10. A consumed RAP API must change: an optional field becomes mandatory and an action parameter changes. How do you handle it?

Both are breaking changes: existing consumers would send requests that now fail, or call the action with the old parameter shape. Do not change the consumed projection/interface in place. Create a new projection (or interface) and service definition for the new contract and add it as a new service version, while the old one stays available. Communicate the change, let consumers migrate, then retire the old version. Compatible changes — new optional fields, new actions, validations that accept previously valid data — can be made in place. Keep strict ( 2 ) and document the contract so reviewers can classify changes quickly.

Related lesson

Behavior Definitions Part 1: Reading a BDEF as the BO Contract

Related topics

Next practice step

Go deeper on this topic