RAP Basics Part 1: RAP Architecture — Layers, Artifacts and When RAP Fits
Free sample lesson · open to everyone
The architect's map of the ABAP RESTful Application Programming Model: the data model (CDS), behavior (BDEF + behavior pool), projection, service definition and service binding, how a Fiori request flows through them, and when RAP is the right choice versus SEGW or classic development.
In this lessonShow sectionsHide sections
Visual overview
The situation: a real project scenario
A global pharma client wanted a Fiori app for field-sales sample requests on S/4HANA 2022. The first design from the team was SEGW with custom DPC_EXT code and a freestyle UI5 app — the pattern they knew from ECC. The architect reviewed it against the target: clean core, upgrade-safe, and a second consumer (a CRM integration) needing the same API.
The team switched to a managed RAP BO with draft: one BO, two bindings (OData V4 UI for Fiori Elements, OData V4 Web API for the CRM). Standard CRUD needed no code; only three validations and one action were written. Build effort dropped by roughly 40% compared with the SEGW estimate, and the upgrade to 2023 needed no adaptation.
Explanation
RAP, the ABAP RESTful Application Programming Model, is the standard SAP model for transactional apps and APIs in S/4HANA and the SAP BTP ABAP Environment: CDS handles the data, a behavior definition (BDEF) handles the behavior, and a service definition plus service binding handle exposure.
It became available on-premise from release 1909 and is fully established from 2020 onward, and it replaces the SEGW + DPC_EXT pattern for new transactional development — it's also the model SAP itself uses for new standard apps and released APIs, as part of clean core.
This series covers it across eleven parts: RAP architecture, layers and when RAP fits (this part); data model design — tables, keys, administrative fields, interface views; the projection layer and metadata extensions; implementation types — managed, unmanaged, additional and unmanaged save; root entity, child entity and composition; behavior definition — CRUD, field control and features; actions, determinations and validations as design decisions; service definition, service binding and OData exposure; behavior implementation — handler and saver classes; EML (Entity Manipulation Language); and draft, locking and authorization.
Every RAP business object is really a stack of artifacts. The data model consists of database tables plus interface CDS view entities (ZI_*), connected by composition. The behavior layer has the behavior definition (BDEF), which declares what the BO can do, and the behavior pool (class ZBP_*), which implements the actual logic.
The projection layer has projection views (ZC_*) and a projection BDEF, which select what a specific app or API is allowed to use. And the business service layer has a service definition, specifying which entities to expose, and a service binding, specifying the protocol — OData V2 or V4, for UI or as a Web API.
The RAP framework itself handles the OData protocol, the transactional buffer, draft handling, locking, and ETags, leaving you to write only the business logic.
A typical request flows like this: Fiori sends an OData request, such as a PATCH on a travel; that goes through the service binding, to the service definition, to the projection, and down into the interface BO. The RAP runtime puts the change into the transactional buffer, calls your determinations and validations, and then saves everything in one LUW — notably, no DPC_EXT method needs to be written for standard CRUD in a managed BO.
RAP fits naturally for a new Fiori transactional app on S/4HANA 2020 or later, and for a new released API meant for integration, using a Web API binding.
A simple read-only list is better served by CDS with UI annotations (a RAP query without behavior) or by an analytical CDS model; an older release such as ECC or S/4HANA 1610/1709 still relies on SEGW; and heavy legacy logic that must be reused is a case for unmanaged RAP wrapping existing function modules or BAPIs, covered in Part 4.
RAP is not a replacement for everything — read-only analytics stay in CDS analytical models, and mass background jobs stay in classic ABAP or application jobs.
A set of architectural decisions are worth making up front, before any implementation: what the BO boundaries are, meaning what counts as one lock unit of root plus children; whether keys should be UUIDs (technical) or semantic, like an order number; whether the implementation type should be managed or unmanaged; whether draft handling is needed for multi-step Fiori editing; and whether exposure should be a UI service only, or also a Web API for integration.
The general rule is to design the business object first — its entities, keys, and lifecycle — and only then design the UI, not the other way around.
To put this into practice: write down the business object's root entity, child entities, keys, and lifecycle states; decide on managed versus unmanaged and whether draft is needed; create the tables, then the interface views, then the BDEF and behavior pool; create the projection views and projection BDEF; and finally create the service definition and binding, publish it, and preview it. By the end you should be able to name all eight artifacts of a RAP business object and say which layer each one belongs to.
Expert visual walkthrough
RAP Architecture — Layers, Artifacts and When RAP Fits
RAP Basics · Chapter-specific technical teaching map
Architecture hierarchy
CDS interface layer
Behavior definition
Service exposure
Fiori/API
Tutor's chapter takeaway
The architect's map of the ABAP RESTful Application Programming Model: the data model (CDS), behavior (BDEF + behavior pool), projection, service definition and service binding, how a Fiori request flows through them, and when RAP is the right choice versus SEGW or…
In a real project
A global pharma client wanted a Fiori app for field-sales sample requests on S/4HANA 2022. The first design from the team was SEGW with custom DPC_EXT code and a freestyle UI5 app — the pattern they knew from ECC. The…
Watch out for
• Starting with the UI and deriving the data model from screens, producing a BO with the wrong lock boundary. • Choosing RAP for a pure read-only report where a CDS view with UI annotations would be enough. • Choosing SEGW on…
Code example
// ===== STEP 1: artifact map of one RAP BO (naming convention) =====// Table ZTRAVEL_A persistence of the root entity// Interface view ZI_TRAVEL data model, root view entity// BDEF ZI_TRAVEL behavior (managed implementation)// Behavior pool ZBP_I_TRAVEL ABAP class with local handler classes// Projection view ZC_TRAVEL app-specific projection// Projection BDEF ZC_TRAVEL which operations the app may use// Service def. ZUI_TRAVEL exposed entities// Service binding ZUI_TRAVEL_O4 OData V4 - UI // ===== STEP 2: minimal root view entity =====@AccessControl.authorizationCheck: #CHECK@EndUserText.label: 'Travel - root'define root view entity ZI_Travel as select from ztravel_a{ key travel_uuid as TravelUUID, travel_id as TravelID, agency_id as AgencyID, overall_status as OverallStatus, @Semantics.systemDateTime.localInstanceLastChangedAt: true local_last_changed_at as LocalLastChangedAt} // ===== STEP 3: behavior definition (managed) =====managed implementation in class zbp_i_travel unique;strict ( 2 ); define behavior for ZI_Travel alias Travelpersistent table ztravel_alock masterauthorization master ( instance )etag master LocalLastChangedAt{ create; update; delete; field ( readonly, numbering : managed ) TravelUUID;} // ===== STEP 4: service definition =====@EndUserText.label: 'Travel UI service'define service ZUI_TRAVEL { expose ZC_Travel as Travel;}// Service binding ZUI_TRAVEL_O4 is created in ADT (OData V4 - UI) and published.Watch out
Common mistakes
- Starting with the UI and deriving the data model from screens, producing a BO with the wrong lock boundary.
- Choosing RAP for a pure read-only report where a CDS view with UI annotations would be enough.
- Choosing SEGW on S/4HANA 2020+ for a new app "because the team knows it", creating new technical debt.
- Putting business logic in the projection layer instead of the interface BO.
- Forgetting that one BO can serve several consumers through several projections/bindings.
Do this
Best practices
- Design the BO (entities, keys, lifecycle, lock unit) before creating any artifact.
- Follow a naming convention (ZI_/ZC_/ZBP_/ZUI_/ZAPI_) across the project.
- Keep business logic in the interface BO; projections only restrict and shape.
- Use managed + draft as the default for new Fiori transactional apps; justify deviations.
- Plan exposure: UI service and Web API as separate bindings on separate projections.
In the interview
Interview angle
Questions: "Explain the RAP architecture", "Which artifacts make up a RAP business object?", "When would you not use RAP?"
Strong answer: names the layers (data model with CDS, behavior with BDEF and behavior pool, projection, service definition and binding), explains that the RAP runtime handles protocol, buffer, locking and draft, and gives clear decision criteria — RAP for new transactional apps and released APIs on S/4HANA 2020+ or BTP, SEGW for older releases, CDS analytics for read-only reporting. Architect-level candidates talk about BO boundaries and one BO serving multiple consumers.
Practice this lesson
Quick check
0 of 3 questions attempted
Question 1 of 3
For a new transactional Fiori app on S/4HANA 2022, why is RAP generally preferred over SEGW?
Question 2 of 3
Which requirement is the weakest fit for building a RAP business object?
Question 3 of 3
Which pair of artifacts forms the business-service (exposure) layer of a RAP business object?
Practise this in an interview
Answer in your own words and get instant feedback, the way an interviewer would judge it.
1What is RAP in SAP ABAP?
2How does RAP fit S/4HANA Clean Core?
Try a related Code Lab
This published exercise covers the same SAP topic. Apply the ideas in a hands-on scenario, then return to review your answers.
Open: Direct Table Update Bypassing RAP Behavior →Was this lesson helpful?
Keep exploring
Interview questions on this topic
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.