Skip to main content

Module 27: RAP (RESTful ABAP Programming Model)

RAP (RESTful ABAP Programming Model) is SAP’s strategic framework for building

  • Transactional business applications
  • OData V4 services
  • Fiori Elements apps

RAP is model-driven, CDS-centric, and behavior-oriented.


1. What is RAP?

Definition

RAP is a programming model that allows you to define:

  • Data model (CDS)
  • Behavior (what is allowed)
  • Transactions (handled by framework)
  • OData exposure (automatic)
SAP Direction

All new S/4HANA developments must use RAP.


2. Core Building Blocks of RAP

CDS Data Model

Behavior Definition

Behavior Implementation

Service Definition & Binding

OData V4 / Fiori

3. Managed vs Unmanaged RAP (Very Important)


3.1 Managed RAP

Managed RAP means:

  • SAP framework handles CRUD
  • SAP framework handles transactions
  • SAP framework handles locking
  • SAP framework handles draft

You only implement business logic hooks.

define behavior for Z_CDS_Sales
persistent table zsales
{
create;
update;
delete;
}

Characteristics

  • Minimal code

  • High consistency

  • Best for new developments

SAP Recommendation

Use Managed RAP by default.

3.2 Unmanaged RAP

Unmanaged RAP means:

  • You manage CRUD logic

  • You manage commits

  • You manage locking

  • You manage persistence

define behavior for Z_CDS_Sales
{
create;
update;
delete;
}

Implementation contains full logic.

Use Cases

  • Legacy tables

  • Existing complex logic

  • Migration scenarios

Use Sparingly

Unmanaged RAP is powerful but maintenance-heavy.

Managed vs Unmanaged – Comparison

AspectManagedUnmanaged
CRUDFrameworkDeveloper
TransactionsFrameworkDeveloper
DraftBuilt-inManual
ComplexityLowHigh
New Projects

4. Behavior Definitions (Heart of RAP)

Behavior Definitions define what is allowed, not how.

4.1 Behavior Definition Example

define behavior for Z_CDS_Sales
persistent table zsales
lock master
{
create;
update;
delete;

field ( readonly ) created_by, created_on;

validation check_amount on save;
}
Key Idea

Behavior Definitions are declarative contracts.

4.2 Behavior Implementation (Hooks)

CLASS zbp_cds_sales IMPLEMENTATION.

METHOD check_amount.
IF ls_sales-amount < 0.
FAILED VALUE #( ( %msg = new_message(
id = 'ZMSG'
number = '001'
severity = if_abap_behv_message=>severity-error ) ) ).
ENDIF.
ENDMETHOD.

ENDCLASS.

5. RAP Business Objects

What is a Business Object in RAP?

A RAP BO:

  • Represents a real business entity

  • Has lifecycle rules

  • Has validations

  • Has actions

5.1 Actions in RAP

define behavior for Z_CDS_Sales
{
action approve result [1] $self;
}

Usage:

POST /Sales(1)/approve
RAP Advantage

Actions allow business operations beyond CRUD.

6. Draft Handling (Game Changer)

What is Draft?

Draft allows:

  • Save-incomplete data

  • Resume later

  • Multi-user editing safety

define behavior for Z_CDS_Sales
with draft
{
create;
update;
delete;
}
Framework Magic

RAP automatically creates:

  • Draft tables

  • Draft lifecycle handling

  • Locking

Draft Benefits

BenefitDescription
User ExperienceSave & resume
ConsistencySafe edits
EffortZero manual code
Fiori Elements

Draft is mandatory for complex Fiori apps.

7. RAP vs BOPF

What is BOPF?

BOPF (Business Object Processing Framework) is the predecessor of RAP.

7.1 RAP vs BOPF

AspectBOPFRAP
EraECC / Early S/4S/4HANA
Programming ModelComplex OODeclarative
CDS-Centric
OData IntegrationIndirectNative
Draft HandlingManualBuilt-in
PerformanceMediumHigh
Learning CurveSteepLower
Future

8. Common RAP Mistakes

Avoid These
  • Using Unmanaged RAP unnecessarily

  • Putting business logic in CDS

  • Ignoring validations

  • Treating RAP like SEGW

  • Overcomplicating behavior

9. Interview-Grade Explanation

Q: Why did SAP introduce RAP?

Answer:

SAP introduced RAP to provide a CDS-based, model-driven framework with built-in transaction handling, draft support, authorization, and OData exposure, replacing code-heavy models like SEGW and BOPF.

This Answer Scores High

Clear, strategic, and future-oriented.

10. Summary

  • RAP is SAP’s strategic backend model

  • Managed RAP is preferred

  • Behavior definitions define allowed operations

  • Business objects model real entities

  • Draft handling is built-in

  • RAP replaces BOPF

11. Practice Exercises

  • Create a managed RAP BO.

  • Add validation logic.

  • Enable draft handling.

  • Implement an action.

  • Compare managed vs unmanaged behavior.

12. What’s Next?

➡️ Module 28: Authorization Concepts

Learning Tip

If you master RAP, you are future-proof as an ABAP developer.