RAP – Building a Business Object in SAP (2026 Guide)

RAP in SAP: Building a Business Object Guide 2026 | ABAP Zero to Hero
ABAP Zero to Hero

Chapter 17  ·  Modern ABAP

RAP — Business Object

Build a complete transactional SAP application with the RESTful ABAP Programming Model — CDS, Behavior, EML, and OData.

Chapter 17 of 20 21 min read Part 4: Modern ABAP 10 Interview Q&A

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.

The big picture RAP is not just another tool. It is a completely different way of thinking about application development. You do not write screens. You do not write SELECT statements scattered through your code. You define a Business Object — a digital representation of a real-world entity — and the framework handles the rest.

🎯 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.

Analogy Think of a Business Object as a digital employee. It has data (the employee’s details), it has behavior (the employee can be hired, promoted, or fired), and it has rules (only HR can fire). You define the employee once, and it works the same way whether accessed from a Fiori app, a report, or an external system.

Why RAP matters in 2026

ReasonWhat It Means
Cloud-readyWorks on BTP ABAP Environment and S/4HANA Cloud
Clean CoreUses only released APIs, ensuring upgrade safety
Fiori-nativeOData services are auto-generated, Fiori Elements apps work out of the box
TransactionalBuilt-in LUW (Logical Unit of Work) handling for data consistency
Draft-enabledUsers can save incomplete work without committing
Standard skillEvery new SAP project in 2026 uses RAP

🏗️ RAP Architecture — The Layers

RAP has four main layers. Understanding them is the key to understanding RAP.

LayerWhat It DoesTechnology
Data ModelDefines the structure — tables and CDS ViewsDDIC Tables + CDS Views
BehaviorDefines what operations are allowed and how they behaveBehavior Definition + Implementation
ServiceExposes the business object as an OData serviceService Definition + Service Binding
ConsumptionConsumes the service in a Fiori app or external systemFiori Elements / SAPUI5 / API
The one-line summary RAP = Data Model + Behavior + Service + Consumption. Everything flows from the data model up.

⚖️ Managed vs Unmanaged RAP

This is the most important decision you make when starting a RAP project. It affects everything that follows.

AspectManaged RAPUnmanaged RAP
CRUD operationsSAP handles automaticallyYou implement manually
Transactional consistencyBuilt-inYou manage explicitly
Draft handlingOut of the boxNot supported (or requires custom work)
Lock managementAutomaticManual (ENQUEUE/DEQUEUE)
Code volumeLess codeMore code
FlexibilityLimited to framework patternsFull control
Best forNew apps, standard CRUD, greenfieldLegacy integration, complex custom logic
The golden rule Use Managed by default. Only switch to Unmanaged when the business logic genuinely requires it — for example, when you need to wrap an existing BAPI or function module. Most real-world RAP projects use Managed.

📜 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

LineMeaning
managed implementation in class ZBP_TRAVELUses Managed RAP; CRUD handled by framework; logic lives in class ZBP_TRAVEL
define behavior for ZI_TravelThe CDS interface view this behavior belongs to
persistent table /dmo/travelThe database table where active data is stored
lock masterThis is the root entity; framework manages locks
etag master LastChangedAtField used for optimistic concurrency (ETag)
authorization master ( global )Authorization is checked globally per entity
draft table /dmo/travel_dEnables draft handling with a separate draft table
create; update; delete;Standard CRUD operations enabled
field ( readonly ) TravelIdTravelId cannot be changed after creation
validation validateDates on saveRuns before save; checks BeginDate and EndDate
determination setStatus on modifyAutomatically sets Status whenever data changes
Key insight The BDEF is a declaration, not an implementation. It says what should happen. The actual code — the 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.
MethodTypePurpose
validateDatesValidationBlocks save if EndDate < BeginDate. Adds a message to reported and an entry to failed.
setStatusDeterminationRuns on every modify; sets Status to ‘N’. Uses MODIFY ENTITIES in local mode.
Important 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

StatementPurpose
READ ENTITIESRead data from a business object
MODIFY ENTITIESCreate, update, or delete data
EXECUTE ACTIONTrigger a custom action
COMMIT ENTITIESPersist 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.
The EML flow READ ENTITIES → (optional validation logic) → MODIFY ENTITIES → COMMIT ENTITIES
Critical rule 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.

TablePurpose
Active tableCommitted, “real” data (e.g., /dmo/travel)
Draft tableTemporary working copy (e.g., /dmo/travel_d)

The draft lifecycle

ActionWhat Happens
EditFramework copies active data → draft table
Auto-saveEvery few seconds, draft table is updated (lightweight, no full validation)
ActivateFull validation + determination run; draft → active; draft deleted
DiscardDraft deleted; active data untouched
ResumeUser 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; }
}
Why validations don’t fire on every keystroke Determinations and validations declared 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_Travel is 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.

SettingValue
Binding typeOData V4 – UI
Service DefinitionZUI_TRAVEL_O4
StatusPublished
Entity SetTravel
Service URL/sap/opu/odata4/.../ZUI_TRAVEL_O4/
OData V4 is recommended for all new RAP services. V2 is only for compatibility with older Fiori apps.

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.

StepObjectToolPurpose
1Database TableSE11 / ADTPhysical storage
2CDS Interface View (ZI_*)ADTData model + associations
3CDS Projection View (ZC_*)ADTConsumption-specific view
4Behavior Definition (ZR_* / ZI_*)ADTDeclare operations, validations, actions
5Behavior Implementation (ZBP_*)ADTImplement logic
6Service Definition (ZUI_*)ADTExpose entities
7Service BindingADTGenerate OData V4 endpoint
8PreviewADTTest the Fiori Elements app

Naming conventions (standard)

PrefixObject
ZI_*Interface CDS View
ZC_*Consumption/Projection CDS View
ZR_*Behavior Definition (projection)
ZBP_*Behavior Implementation class
ZUI_*Service Definition
Z*_O4Service Binding (OData V4)

⚠️ Common Pitfalls

MistakeConsequenceFix
Forgetting COMMIT ENTITIESData never savedAlways commit after MODIFY
Using IN LOCAL MODE in validationsAuthorizations bypassedUse local mode only in determinations/actions
Not adding %element-* to reportedUI doesn’t highlight the fieldMap messages to fields
Mixing Managed and UnmanagedFramework errorsPick one and stick with it
Using OData V2 for new appsNo draft support in Fiori ElementsUse OData V4
Direct table access in RAP logicClean Core violationAlways 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.

1 What is RAP in SAP ABAP?

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.

2 What is the difference between Managed and Unmanaged RAP?

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.

3 What is a Behavior Definition (BDEF) in RAP?

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.

4 What is Behavior Implementation in RAP?

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.

5 What is EML in RAP?

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.

6 What is the difference between Service Definition and Service Binding?

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.

7 What is Draft Handling in RAP?

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.

8 What is a Business Object in RAP?

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.

9 What is Clean Core and why does RAP matter?

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.

10 What is the RAP development flow?

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.

  1. Create table ZBOOK with fields: BookId, Title, Author, PublishedDate, Genre.
  2. Create interface CDS view ZI_Book with ROOT and @AccessControl.authorizationCheck: #NOT_REQUIRED.
  3. Create projection view ZC_Book.
  4. Write a Managed Behavior Definition ZI_Book with:
    • create, update, delete
    • Validation: PublishedDate must not be in the future
    • Determination: auto-set Genre to ‘General’ if empty
  5. Implement the Behavior Implementation class ZBP_BOOK.
  6. Create Service Definition ZUI_BOOK_O4.
  7. Create Service Binding (OData V4 – UI) and publish.
  8. Preview in Eclipse ADT — test Create, Edit, Delete.
Deliverable A working Fiori Elements list report with create/edit/delete, plus at least one validation that blocks an invalid save.
🎯 Chapter 17 Challenge

Test: Kon Banega Crorepati?

5 questions. ₹1 Crore. Prove you understood RAP. No pressure — restart anytime.

₹1,000 ₹10,000 ₹1,00,000 ₹10,00,000 ₹1 Crore
Question 1 of 5
Score: 0
Q1
🏆
You Did It!
0/5Correct Answers
You won ₹0
➡️ Next Chapter

➡️ Next Chapter

You can now build a complete RAP business object. In Chapter 18, you will go deeper into EML, Validations, and Determinations — advanced patterns used in real projects.

Chapter 18 EML & Validations / Determinations →
Want to Learn Faster?

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 WhatsApp us
Call Now Button