Chapter 17 · Modern ABAP
RAP — Business Object
Build a complete transactional SAP application with the RESTful ABAP Programming Model — CDS, Behavior, EML, and OData.
Everything you have learned so far has been leading to this. CDS Views gave you the data model. Behavior Definitions give you the business logic. Service Bindings expose it to the world. And the result is a complete, transactional, cloud-ready SAP application.
This is RAP — the RESTful ABAP Programming Model. It is the standard for all new SAP development on S/4HANA and BTP. If you have been building classic ABAP for years, this is the chapter that changes how you build applications. If you are new to ABAP, this is your foundation for the future.
🎯 What You Will Learn in This Chapter
- What RAP is and why it replaced classic ABAP application development
- The RAP architecture: Business Objects, CDS Views, Behavior, and Services
- The difference between Managed and Unmanaged RAP
- How to define a Behavior Definition (BDEF)
- How to implement Behavior Implementation classes
- What EML (Entity Manipulation Language) is and how to use it
- How Draft Handling works with the dual-table architecture
- How to expose a RAP business object via Service Definition and Service Binding
- The full RAP development flow from database table to Fiori app
📘 What is RAP?
RAP stands for RESTful ABAP Programming Model. It is SAP’s modern framework for building transactional, cloud-ready applications on SAP S/4HANA and SAP BTP.
Before RAP, building a transactional SAP application meant:
- Writing a custom screen (or Fiori app) separately
- Writing a report or function module for the logic
- Writing your own authorization checks
- Writing your own error handling
- Duplicating code across multiple entry points
RAP replaces all of this with a single, model-driven approach. You define a Business Object — and the framework handles the rest.
Why RAP matters in 2026
| Reason | What It Means |
|---|---|
| Cloud-ready | Works on BTP ABAP Environment and S/4HANA Cloud |
| Clean Core | Uses only released APIs, ensuring upgrade safety |
| Fiori-native | OData services are auto-generated, Fiori Elements apps work out of the box |
| Transactional | Built-in LUW (Logical Unit of Work) handling for data consistency |
| Draft-enabled | Users can save incomplete work without committing |
| Standard skill | Every new SAP project in 2026 uses RAP |
🏗️ RAP Architecture — The Layers
RAP has four main layers. Understanding them is the key to understanding RAP.
| Layer | What It Does | Technology |
|---|---|---|
| Data Model | Defines the structure — tables and CDS Views | DDIC Tables + CDS Views |
| Behavior | Defines what operations are allowed and how they behave | Behavior Definition + Implementation |
| Service | Exposes the business object as an OData service | Service Definition + Service Binding |
| Consumption | Consumes the service in a Fiori app or external system | Fiori Elements / SAPUI5 / API |
⚖️ Managed vs Unmanaged RAP
This is the most important decision you make when starting a RAP project. It affects everything that follows.
| Aspect | Managed RAP | Unmanaged RAP |
|---|---|---|
| CRUD operations | SAP handles automatically | You implement manually |
| Transactional consistency | Built-in | You manage explicitly |
| Draft handling | Out of the box | Not supported (or requires custom work) |
| Lock management | Automatic | Manual (ENQUEUE/DEQUEUE) |
| Code volume | Less code | More code |
| Flexibility | Limited to framework patterns | Full control |
| Best for | New apps, standard CRUD, greenfield | Legacy integration, complex custom logic |
📜 Behavior Definition (BDEF) — The Contract
A Behavior Definition is a file that declares what a RAP business object can do. It is written in a domain-specific language and lives alongside your CDS Views in Eclipse ADT.
What a BDEF declares
- Implementation type — Managed or Unmanaged
- Operations — Create, Update, Delete, Read
- Validations — Rules that must pass before saving
- Determinations — Automatic logic that runs when data changes
- Actions — Custom operations (approve, cancel, etc.)
- Draft handling — Whether drafts are enabled
- Authorization — How permissions are checked
- Field mappings — Which fields map to which table columns
A minimal Managed BDEF
managed implementation in class ZBP_TRAVEL unique;
define behavior for ZI_Travel
persistent table /dmo/travel
lock master
etag master LastChangedAt
authorization master ( global )
draft table /dmo/travel_d
{
create;
update;
delete;
field ( readonly ) TravelId;
validation validateDates on save { field BeginDate, EndDate; }
determination setStatus on modify { field Status; }
}
Breaking it down
| Line | Meaning |
|---|---|
managed implementation in class ZBP_TRAVEL | Uses Managed RAP; CRUD handled by framework; logic lives in class ZBP_TRAVEL |
define behavior for ZI_Travel | The CDS interface view this behavior belongs to |
persistent table /dmo/travel | The database table where active data is stored |
lock master | This is the root entity; framework manages locks |
etag master LastChangedAt | Field used for optimistic concurrency (ETag) |
authorization master ( global ) | Authorization is checked globally per entity |
draft table /dmo/travel_d | Enables draft handling with a separate draft table |
create; update; delete; | Standard CRUD operations enabled |
field ( readonly ) TravelId | TravelId cannot be changed after creation |
validation validateDates on save | Runs before save; checks BeginDate and EndDate |
determination setStatus on modify | Automatically sets Status whenever data changes |
validateDates and setStatus logic — lives in the Behavior Implementation class.
⚙️ Behavior Implementation — The Logic
The Behavior Implementation is an ABAP class (conventionally named ZBP_*) that implements the methods declared in the BDEF. In Managed RAP, you only implement validations, determinations, actions, and authorization — never CRUD.
The class skeleton
CLASS zbp_travel DEFINITION
PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_abap_behv_message.
INTERFACES if_abap_behavior_handler.
PRIVATE SECTION.
METHODS validateDates FOR VALIDATE ON SAVE
IMPORTING keys FOR Travel~validateDates.
METHODS setStatus FOR DETERMINE ON MODIFY
IMPORTING keys FOR Travel~setStatus.
ENDCLASS.
Implementing a validation
CLASS zbp_travel IMPLEMENTATION.
METHOD validateDates.
" Read the affected entities
READ ENTITIES OF zi_travel IN LOCAL MODE
ENTITY Travel
FIELDS ( BeginDate EndDate )
WITH CORRESPONDING #( keys )
RESULT DATA(lt_travel).
LOOP AT lt_travel INTO DATA(ls_travel).
IF ls_travel-EndDate < ls_travel-BeginDate.
APPEND VALUE #( %tky = ls_travel-%tky ) TO failed-travel.
APPEND VALUE #(
%tky = ls_travel-%tky
%msg = new_message_with_text(
severity = if_abap_behv_message=>severity-error
text = 'End date cannot be before begin date' )
%element-BeginDate = if_abap_behv=>mk-on
) TO reported-travel.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD setStatus.
" Determinations run automatically when data changes
MODIFY ENTITIES OF zi_travel IN LOCAL MODE
ENTITY Travel
UPDATE FIELDS ( Status )
WITH VALUE #( FOR key IN keys
( %tky = key-%tky
Status = 'N' ) ). " N = New
ENDMETHOD.
ENDCLASS.
| Method | Type | Purpose |
|---|---|---|
validateDates | Validation | Blocks save if EndDate < BeginDate. Adds a message to reported and an entry to failed. |
setStatus | Determination | Runs on every modify; sets Status to ‘N’. Uses MODIFY ENTITIES in local mode. |
IN LOCAL MODE bypasses authorization and other checks — correct for internal framework logic like determinations.
🔧 EML — Entity Manipulation Language
EML is how you interact with RAP business objects from ABAP code. It is an extension of the ABAP language and enforces all BDEF logic (validations, authorizations, determinations) automatically.
The four core EML statements
| Statement | Purpose |
|---|---|
READ ENTITIES | Read data from a business object |
MODIFY ENTITIES | Create, update, or delete data |
EXECUTE ACTION | Trigger a custom action |
COMMIT ENTITIES | Persist changes to the database |
READ ENTITIES example
READ ENTITIES OF zi_travel
ENTITY Travel
ALL FIELDS
WITH VALUE #( ( TravelId = '00000001' ) )
RESULT DATA(lt_travel)
FAILED DATA(ls_failed)
REPORTED DATA(ls_reported).
LOOP AT lt_travel INTO DATA(ls_travel).
WRITE: / ls_travel-TravelId, ls_travel-Description.
ENDLOOP.
MODIFY ENTITIES example (Create)
MODIFY ENTITIES OF zi_travel
ENTITY Travel
CREATE FIELDS ( Description BeginDate EndDate )
WITH VALUE #( (
%cid = 'CID_1'
Description = 'Business Trip to Berlin'
BeginDate = '20260401'
EndDate = '20260405' ) )
MAPPED DATA(ls_mapped)
FAILED DATA(ls_failed)
REPORTED DATA(ls_reported).
" Always commit after modify
COMMIT ENTITIES
RESPONSE OF zi_travel
FAILED DATA(ls_commit_failed)
REPORTED DATA(ls_commit_reported).
MODIFY ENTITIES example (Update)
MODIFY ENTITIES OF zi_travel
ENTITY Travel
UPDATE FIELDS ( Description )
WITH VALUE #( (
TravelId = '00000001'
Description = 'Updated description' ) )
FAILED DATA(ls_failed)
REPORTED DATA(ls_reported).
COMMIT ENTITIES.
EXECUTE ACTION example
EXECUTE ACTION acceptTravel
ENTITY Travel
FROM VALUE #( ( TravelId = '00000001' ) )
FAILED DATA(ls_failed)
REPORTED DATA(ls_reported).
COMMIT ENTITIES.
MODIFY ENTITIES does not save to the database. Only COMMIT ENTITIES does. This is what gives RAP its transactional integrity.
📝 Draft Handling — The Dual-Table Architecture
Draft Handling lets users save incomplete work without triggering full business rules. It uses two tables.
| Table | Purpose |
|---|---|
| Active table | Committed, “real” data (e.g., /dmo/travel) |
| Draft table | Temporary working copy (e.g., /dmo/travel_d) |
The draft lifecycle
| Action | What Happens |
|---|---|
| Edit | Framework copies active data → draft table |
| Auto-save | Every few seconds, draft table is updated (lightweight, no full validation) |
| Activate | Full validation + determination run; draft → active; draft deleted |
| Discard | Draft deleted; active data untouched |
| Resume | User reopens; draft is reloaded |
Draft-aware BDEF additions
define behavior for ZI_Travel
persistent table /dmo/travel
draft table /dmo/travel_d
lock master
etag master LastChangedAt
{
create;
update;
delete;
draft actions
{
Edit;
Activate;
Discard;
Resume;
}
validation validateDates on save { field BeginDate, EndDate; }
}
on save fire only during Activate or Prepare, not during draft auto-save. This is intentional: users should be able to enter partial, temporarily invalid data without being blocked.
🌐 Service Definition & Service Binding
Once your business object is complete, you expose it as an OData service.
Service Definition
A Service Definition declares which entities are exposed.
@EndUserText.label: 'Travel Service'
define service ZUI_TRAVEL_O4 {
expose ZC_Travel as Travel;
}
ZC_Travelis the projection/consumption CDS view (not the interface view).expose ... as ...gives the entity an external name.
Service Binding
A Service Binding turns the Service Definition into a runtime endpoint.
| Setting | Value |
|---|---|
| Binding type | OData V4 – UI |
| Service Definition | ZUI_TRAVEL_O4 |
| Status | Published |
| Entity Set | Travel |
| Service URL | /sap/opu/odata4/.../ZUI_TRAVEL_O4/ |
Preview
Once published, click Preview in Eclipse ADT to open the Fiori Elements app. You get:
- List report with filters
- Object page with details
- Create / Edit / Delete buttons
- Draft handling (Save, Activate, Discard)
- All validations and actions wired up
Without writing a single line of UI code.
🧭 The Complete RAP Development Flow
Here is the full sequence from scratch to a working Fiori app.
| Step | Object | Tool | Purpose |
|---|---|---|---|
| 1 | Database Table | SE11 / ADT | Physical storage |
| 2 | CDS Interface View (ZI_*) | ADT | Data model + associations |
| 3 | CDS Projection View (ZC_*) | ADT | Consumption-specific view |
| 4 | Behavior Definition (ZR_* / ZI_*) | ADT | Declare operations, validations, actions |
| 5 | Behavior Implementation (ZBP_*) | ADT | Implement logic |
| 6 | Service Definition (ZUI_*) | ADT | Expose entities |
| 7 | Service Binding | ADT | Generate OData V4 endpoint |
| 8 | Preview | ADT | Test the Fiori Elements app |
Naming conventions (standard)
| Prefix | Object |
|---|---|
ZI_* | Interface CDS View |
ZC_* | Consumption/Projection CDS View |
ZR_* | Behavior Definition (projection) |
ZBP_* | Behavior Implementation class |
ZUI_* | Service Definition |
Z*_O4 | Service Binding (OData V4) |
⚠️ Common Pitfalls
| Mistake | Consequence | Fix |
|---|---|---|
Forgetting COMMIT ENTITIES | Data never saved | Always commit after MODIFY |
Using IN LOCAL MODE in validations | Authorizations bypassed | Use local mode only in determinations/actions |
Not adding %element-* to reported | UI doesn’t highlight the field | Map messages to fields |
| Mixing Managed and Unmanaged | Framework errors | Pick one and stick with it |
| Using OData V2 for new apps | No draft support in Fiori Elements | Use OData V4 |
| Direct table access in RAP logic | Clean Core violation | Always use EML |
🎤 Interview Questions & Answers
RAP is the single most-tested modern ABAP topic in 2026. Every S/4HANA or BTP interview includes these questions.
RAP (RESTful ABAP Programming Model) is SAP’s modern framework for building cloud-ready, transactional applications on S/4HANA and BTP. It combines CDS Views for data modeling, Behavior Definitions for business logic, and Service Bindings for OData exposure. RAP is the standard for new SAP development and is required for Clean Core compliance.
In Managed RAP, SAP automatically handles CRUD operations, transactional consistency, and draft handling. In Unmanaged RAP, you implement all CRUD operations manually, giving you full control over database operations. Use Managed for greenfield projects; use Unmanaged when wrapping legacy code, reusing BAPIs, or implementing complex custom logic.
A Behavior Definition declares what operations a RAP business object supports — Create, Update, Delete, Actions, Validations, and Determinations. It also specifies whether the scenario is Managed or Unmanaged, whether draft handling is enabled, and how authorization is enforced. The BDEF is the contract between the framework and your business logic.
Behavior Implementation is the ABAP class (usually named ZBP_*) that contains the actual code for the business logic declared in the Behavior Definition. It implements methods for validations, determinations, actions, and (in Unmanaged scenarios) CRUD operations. The BDEF says what the app should do; the Behavior Implementation says how it does it.
EML (Entity Manipulation Language) is an extension of ABAP syntax used to interact with RAP business objects. It provides statements like READ ENTITIES, MODIFY ENTITIES, EXECUTE ACTION, and COMMIT ENTITIES. EML ensures all business logic, authorizations, and validations defined in the BDEF are enforced when data is manipulated.
A Service Definition specifies which CDS views and entities of a business object are exposed as a service. A Service Binding makes that service consumable by choosing a protocol (OData V2 or V4) and generating the runtime endpoint. Without a Service Binding, a RAP business object cannot be consumed by Fiori apps or external systems.
Draft Handling is a RAP feature that allows users to save incomplete work without triggering full business rules. It uses a dual-table architecture: an active table for committed data and a draft table for temporary working copies. Users can Edit, Activate, Discard, and Resume drafts. Determinations and validations declared ON SAVE only fire during Activate or Prepare, not during every draft auto-save.
A Business Object in RAP is a digital representation of a real-world entity, like a Sales Order or Travel. It encapsulates both data (attributes) and behavior (operations like create, approve, cancel). Business Objects can have hierarchical relationships — for example, a Sales Order (root) with multiple Order Items (child entities). The root entity is identified by the ROOT keyword in the CDS data definition.
Clean Core is SAP’s principle that custom code should not modify SAP standard objects, ensuring upgrade safety. RAP supports Clean Core by using only released SAP APIs (C1 contract), avoiding direct table access, and building extensions as separate business objects. RAP is the recommended approach for all new development on S/4HANA and BTP.
The RAP development flow is: 1) Create database table, 2) Create CDS Interface Views, 3) Create CDS Projection/Consumption View, 4) Create Behavior Definition (BDEF), 5) Create Behavior Implementation class, 6) Create Service Definition, 7) Create Service Binding (OData V4), 8) Preview the Fiori Elements app. The result is a working, transactional SAP application.
🛠 Practice Task for This Chapter
Build a complete RAP business object for a Book Management app. This mirrors the real project pattern you will use on the job.
- Create table
ZBOOKwith fields: BookId, Title, Author, PublishedDate, Genre. - Create interface CDS view
ZI_BookwithROOTand@AccessControl.authorizationCheck: #NOT_REQUIRED. - Create projection view
ZC_Book. - Write a Managed Behavior Definition
ZI_Bookwith:create,update,delete- Validation:
PublishedDatemust not be in the future - Determination: auto-set
Genreto ‘General’ if empty
- Implement the Behavior Implementation class
ZBP_BOOK. - Create Service Definition
ZUI_BOOK_O4. - Create Service Binding (OData V4 – UI) and publish.
- Preview in Eclipse ADT — test Create, Edit, Delete.
Test: Kon Banega Crorepati?
5 questions. ₹1 Crore. Prove you understood RAP. No pressure — restart anytime.
Explore Our Instructor-Led SAP & IT Courses
Self-study works. But if you want guided training, real project practice, and placement support — here are the courses we offer. Book a free demo before you decide.
WhatsApp us