RAP Behavior Definition - Managed

Published: November 2025

What Is SAP RAP Behavior Definition?

In the ABAP RESTful Application Programming Model (RAP), the Behavior Definition (BDEF) is the central artifact where you describe:

In short:

How to Create a Behavior Definition (Managed Scenario)

Before creating a behavior definition, CDS Entity View must exist. Following are step-by-step instrution on how to create a behavior definition:

Example of Managed Behavior Definition - Base CDS View Entity

	
		managed implementation in class zbp_i_student_m_bd unique;
		strict ( 2 );

		define behavior for ZI_STUDENT_M_BD //alias 
		persistent table zstudent_m_bd
		lock master
		authorization master ( instance )
		//etag master 
		{
		  create ( authorization : global );
		  update;
		  delete;
		  field ( readonly ) Id;
		}
	

The complete Base CDS view entity behavior definition would be like this:

	
		managed implementation in class zbp_i_student_m_bd unique;
		strict ( 2 );

		define behavior for ZI_STUDENT_M_BD alias Student
		persistent table zstudent_m_bd
		lock master
		authorization master ( instance )
		//etag master 
		{
		  create ( authorization : global );
		  update;
		  delete;

		  field ( numbering : managed , readonly ) Id;

		  action (features : instance ) setAdmitted result [1] $self;  // action will return one result (a single instance) AND $self: return that same student record structure
		  action (features : instance ) clearAdmitted result [1] $self;

		  mapping for zstudent_m_bd {
			Id = id;
			Firstname = firstname;
			Lastname = lastname;
			Age = age;
			Course = course;
			Courseduration = courseduration;
			Status = status;
			Gender = gender;
			Dob = dob;
			Lastchangedat = lastchangedat;
			Locallastchangedat = locallastchangedat;
		  }
		}	
	

Example of Managed Behavior Definition - Projection/Consumption CDS View Entity

	
		projection;
		strict ( 2 );

		define behavior for ZC_STUDENT_M_BD //alias 
		{
		  use create;
		  use update;
		  use delete;
		}
	

And the complete Projection CDS view entity behavior definition would be like this:

	
		projection;
		strict ( 2 );

		define behavior for ZC_STUDENT_M_BD //alias 
		{
		  use create;
		  use update;
		  use delete;

		  use action setAdmitted;
		  use action clearAdmitted;
		}
	

Further Information

Managed

This is indicating that behavior definition needs to be generated is a Managed RAP. With managed RAP the CRUD process is taken care by the framework, without manual changes added to the implementation class.

Implementation Class

Once the BDEF has been created, implementation class needs to be generated. To create implementation class, place cursor on first BDEF line showing implementation class and select quick fix or press Control+1

	
		managed implementation in class zbp_i_student_m_bd unique;
	

The class generated contains "Global Class" and "Local Types". Global class generated would be like as follow:

	
		CLASS zbp_i_student_m_bd DEFINITION PUBLIC ABSTRACT FINAL FOR BEHAVIOR OF zi_student_m_bd.
		ENDCLASS.

		CLASS zbp_i_student_m_bd IMPLEMENTATION.
		ENDCLASS.
	

And the local types would be something like the follow:

	
		CLASS lhc_Student DEFINITION INHERITING FROM cl_abap_behavior_handler.
		  PRIVATE SECTION.

			METHODS get_instance_features FOR INSTANCE FEATURES
			  IMPORTING keys REQUEST requested_features FOR Student RESULT result.

			METHODS get_instance_authorizations FOR INSTANCE AUTHORIZATION
			  IMPORTING keys REQUEST requested_authorizations FOR Student RESULT result.

			METHODS get_global_authorizations FOR GLOBAL AUTHORIZATION
			  IMPORTING REQUEST requested_authorizations FOR Student RESULT result.

			METHODS clearAdmitted FOR MODIFY
			  IMPORTING keys FOR ACTION Student~clearAdmitted RESULT result.

			METHODS setAdmitted FOR MODIFY
			  IMPORTING keys FOR ACTION Student~setAdmitted RESULT result.

		ENDCLASS.

		CLASS lhc_Student IMPLEMENTATION.

		  METHOD get_instance_features.
		  ENDMETHOD.

		  METHOD get_instance_authorizations.
		  ENDMETHOD.

		  METHOD get_global_authorizations.
		  ENDMETHOD.

		  METHOD clearAdmitted.
		  ENDMETHOD.

		  METHOD setAdmitted.
		  ENDMETHOD.

		ENDCLASS.
	

unique

strict

persistent table

lock (master/dependent)

authorization

etag

Field

In the ABAP RESTful Application Programming Model (RAP), the field command is used in the behavior definition (BDEF) to define the behavioral properties of individual fields of a business object. It allows you to control whether a field is:

numbering

Mapping

Mapping is done between fields on Base CDS View Entity and fields on database table. The left side of the mapping is CDS View Entity field, while the right side is database table fields.

		
		...
		define behavior for ZI_STUDENT_M_BD alias Student
		...
		{
		  mapping for zstudent_m_bd {
			Id = id;
			Firstname = firstname;
			Lastname = lastname;
			Age = age;
			Course = course;
			Courseduration = courseduration;
			Status = status;
			Gender = gender;
			Dob = dob;
			Lastchangedat = lastchangedat;
			Locallastchangedat = locallastchangedat;
		  }
		  ...
		}