What is a behavior definition in RAP, and what do you actually write in one?
Say your answer out loud first.
Practise another way
The behavior definition, the BDEF, is the transactional contract of a RAP business object. The CDS views describe the data; the BDEF says what may be done with it. The header sets the implementation type (managed or unmanaged), strict mode and draft.
Per entity, the BDEF declares the persistent table, lock, ETag and authorization masters. Then comes the body: create, update, delete, field rules, validations, determinations, actions and the mapping. The code behind it lives in the behavior pool.
What it is. A behavior definition (BDEF) is a repository object written in the Behavior Definition Language (BDL). It has the same name as the root CDS entity and describes the transactional behavior of the whole business object: its operations, its rules and how they are implemented.
A CDS view can be read without a BDEF; the moment you want to create, change or lock data through RAP, you need one.
The three parts, top to bottom
managed implementation in class zbp_r_request unique;
strict ( 2 );
with draft;
define behavior for ZR_Request alias Request
persistent table zrequest
draft table zrequest_d
lock master total etag LastChangedAt
authorization master ( instance )
etag master LocalLastChangedAt
{
create; update; delete;
field ( readonly ) RequestID, LastChangedAt;
field ( mandatory ) Title;
validation checkAmount on save { create; field Amount; }
determination setStatus on modify { create; }
action approve result [1] $self;
draft action Edit; draft action Activate optimized;
draft action Discard; draft action Resume;
draft determine action Prepare;
mapping for zrequest corresponding;
}
- Header: implementation type (
managedorunmanaged, optionallywith additional saveorwith unmanaged save), the behavior pool class,strict ( 2 )for SAP's current extra syntax checks, andwith draftorwith collaborative draft. - Entity behavior characteristics after
define behavior for: persistent table, draft table,lock master,etag master,authorization master, numbering such aslate numbering. - Entity body in braces: standard operations, create-by-association for children, static field characteristics (
readonly,mandatory), validations, determinations, actions and functions, draft actions, side effects and the field mapping to the table.
What it does not contain. No ABAP logic. Every validation, determination or action you declare becomes a handler method that ADT can generate with a quick fix in the behavior pool. In a managed BO, plain CRUD needs no code at all.
Kinds of BDEF. The base (interface) BDEF above holds the real behavior. A projection BDEF (projection; with use create;, use action approve;) exposes a subset to one service.
There are also interface BDEFs for released BO interfaces, abstract BDEFs for parameter structures, and BDEF extensions. SAP's cheat sheet keeps a full syntax tour.
Fresher tip: when asked, sketch the three parts and say which one controls locking and which one draft. That shows you have written one, not just read about it.
Separates data (CDS) from behavior (BDEF), names the header, characteristics and body with real keywords, and says logic lives in the behavior pool.
Calls the BDEF 'the file with CRUD' or confuses it with the service definition or the metadata extension.
Saying the BDEF contains the validation code. It only declares the validation and its trigger; the code is a handler method in the behavior pool.
- What does strict ( 2 ) add, and would you switch it off?
- Which entity must have its own define behavior for, and is it optional for children?
- What is the difference between the base BDEF and the projection BDEF?
1 candidate write-up, 2 official pages and 3 prep guides. Confidence: high. Checked 3 Dec 2026.
- Prep guide Gives the question.
- Prep guide Gives the question.
- Prep guide Gives the question.
- Official page Backs the answer.
- Official page Backs the answer.
- Candidate write-up Gives the question.