Appearance
Lesson 10 — RAP Foundations: Business Object Structure
Until now, your application architecture has looked roughly like this:
text
Runner
↓
Reader
↓
CDS / ABAP SQL
↓
Database TableFor controlled persistence exercises, you also used:
text
SQL Lifecycle Class
↓
ABAP SQL
↓
Database TableThat taught you what persistence actually looks like.
Now the architecture changes.
We begin the ABAP RESTful Application Programming Model (RAP).
Today we will not build a service.
We will not build a UI.
We will not write EML.
We will not define create, update, or delete behavior.
Today is about the first RAP question:
What is the business object, structurally?
Lesson information
| Teacher-led time | About 3 hours |
| Self-practice time | About 3 hours |
| Environment | SAP BTP ABAP Trial |
| Prerequisites | Lessons 1–9 + checkpoint project |
| Existing persistence | ZRESV_### |
| New CDS root | ZR_RESERVATION_### |
| Main outcome | RAP Business Object root data model |
| Behavior Definition today? | No — Lesson 11 |
Replace ### with your own student/group suffix.
Learning objectives
After the teacher-led part, you should be able to:
- explain what RAP adds above raw persistence;
- distinguish persistence from a RAP Business Object data model;
- explain the two major parts of a RAP Business Object;
- explain the role of the root entity;
- distinguish
define view entityfromdefine root view entity; - explain why a single-node BO can still have a root;
- create a RAP root CDS View Entity over custom persistence;
- expose business fields with clear CDS names;
- omit the technical client field from the BO model;
- preserve amount/currency semantics;
- add RAP administrative-field semantics;
- explain managed vs unmanaged RAP at a conceptual level;
- explain why managed RAP is the natural first choice for new course persistence;
- explain why Lesson 10 deliberately stops before the Behavior Definition.
1. What is RAP and what is it for?
RAP stands for:
text
ABAP RESTful Application Programming ModelIt is SAP's application programming model for building modern transactional applications and APIs in ABAP Cloud.
RAP gives you a structured way to turn application data into business objects that have:
text
data structure
transactional behavior
business rules
authorization
concurrency control
service exposureInstead of every application inventing its own way to:
text
create data
change data
delete data
validate changes
protect data
report errors
expose APIsRAP provides a consistent framework for doing those things.
A RAP Business Object can later be consumed through different entry points.
For example:
text
ABAP code
↓
EML
↓
RAP Business Objector:
text
Fiori application
↓
OData V4 service
↓
RAP Business Objector:
text
External service consumer
↓
OData service
↓
RAP Business ObjectThe important idea is:
Consumers work with the business object contract rather than directly changing the database table.
RAP is therefore not just:
text
another way to define a CDS viewIt is the framework that connects:
text
Persistence
↓
Business Object structure
↓
Business Object behavior
↓
Application / API consumptionIn this course, we will build those layers gradually.
Today we begin with:
text
Business Object structure2. Where RAP begins
You already own this persistence:
text
ZRESV_###It stores Workshop Reservations.
But a database table is not a complete application-level business contract.
A table knows:
text
columns
types
keys
stored rowsIt does not, by itself, define application behavior such as:
text
which operations are allowed
which fields are read-only
which fields are mandatory
how IDs are generated
how locking works
how optimistic concurrency works
how validation works
which actions exist
how authorization is checked
how transactional changes are savedRAP introduces a business-object abstraction above persistence.
3. The architecture transition
Before RAP, your write exercise looked like:
text
Consumer Class
↓
ABAP SQL
↓
ZRESV_###Later in RAP, normal consumers will work through the business object:
text
Consumer
↓
EML / Business Service
↓
RAP Business Object
↓
PersistenceThe persistence still exists.
RAP does not make the database table disappear.
Instead, RAP gives application code a controlled business contract above it.
4. What is a RAP Business Object?
Conceptually, a RAP Business Object has two major parts:
text
Structure
+
BehaviorStructure
The structure is modeled in CDS.
It describes:
text
entities
fields
keys
relationships
root / child hierarchy
business-facing data modelBehavior
The Behavior Definition describes what consumers may do with those entities.
Examples include:
text
create
update
delete
actions
validations
determinations
field control
locking
authorizationToday we build only:
text
StructureLesson 11 adds:
text
Behavior5. Do we have a complete transactional BO today?
Not yet.
At the end of Lesson 10 you will have:
text
persistence
+
RAP root CDS data modelYou will not yet have the complete transactional behavior contract.
That arrives when the Behavior Definition is added.
Use this mental model:
text
Lesson 10
BO data model / structure
Lesson 11
BO behavior contract6. Business Object structure can be hierarchical
A RAP Business Object may contain:
text
Root
├─ Child
├─ Child
│ └─ Grandchild
└─ ChildFor example:
text
Travel
└─ Booking
└─ Booking SupplementThose internal parent/child relationships are modeled later using:
text
composition
association to parentWe are not learning composition today.
7. A Business Object can also have one node
A BO does not need children.
Our first BO will contain only:
text
ReservationSo structurally:
text
Reservationis both:
text
root entity
+
leaf entityIt is still declared as a root because every BO hierarchy begins at one root.
8. Root does not mean primary key
Do not confuse:
text
root entitywith:
text
key fieldThey describe different ideas.
Root
Describes the entity's role in the BO hierarchy.
text
Reservation
=
top of the Business ObjectKey
Identifies one entity instance.
text
Uuid
=
identity of one Reservation instance9. Root does not mean database root
The root designation belongs to the CDS business-object model.
The physical persistence remains:
text
ZRESV_###The root entity will be:
text
ZR_RESERVATION_###Architecture:
text
ZR_RESERVATION_###
↓
ZRESV_###The CDS root is not another physical database table.
10. Normal CDS View Entity vs root CDS View Entity
You already know:
abap
define view entity ...Today you add:
abap
define root view entity ...A normal View Entity can be used for many query/data-model purposes.
A root View Entity specifically declares:
This entity is the root of a business-object hierarchy.
11. Naming convention
Create:
text
ZR_RESERVATION_###For this course:
text
ZR_means:
text
RAP root/base entityThis is a project naming convention.
The important language feature is not the ZR_ prefix.
It is:
abap
define root view entity12. Inspect the existing persistence
Open:
text
ZRESV_###Recall the structure:
text
client
uuid
reservation_no
customer_name
customer_email
workshop_code
reservation_date
status
fee
currency_code
notes
local_created_by
local_created_at
local_last_changed_by
local_last_changed_at
last_changed_atThe technical key is:
text
client + uuidOur root CDS will transform this storage-oriented structure into a cleaner business-facing entity.
13. Create the root CDS Data Definition
Right-click your package.
Choose:
text
New
→ Other ABAP Repository Object
→ Core Data Services
→ Data DefinitionUse:
text
Name: ZR_RESERVATION_###
Description: Reservation RAP RootChoose the course transport if required.
Choose Finish.
14. Start with the root declaration
Use:
abap
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Reservation'
define root view entity ZR_Reservation_###
as select from zresv_### as Reservation
{
}Do not copy an old-style CDS View template containing:
text
@AbapCatalog.sqlViewNameThis course uses CDS View Entities.
15. Understand define root view entity
The declaration:
abap
define root view entity ZR_Reservation_###states that this CDS entity is intended to be the root entity of a business-object hierarchy.
For today:
text
Reservation
=
root
=
only nodeLater, a root can have compositions.
16. Why select directly from the persistence table?
For this first managed RAP scenario:
text
ZR_RESERVATION_###is a transactional base data model over:
text
ZRESV_###The direct relationship keeps the first BO easy to reason about:
text
CDS field
↔
persistence fieldLesson 11 will make that connection explicit in the Behavior Definition.
17. Do not expose the client field
The table contains:
text
clientDo not expose it as an ordinary BO property.
The CDS root should not contain:
abap
Reservation.client as ClientWhy?
Because client handling is technical data separation managed by the ABAP platform.
This is also a CDS View Entity language rule: the technical client field cannot appear in its select list. Client filtering is implicit. See SAP: CDS View Entity select list.
Consumers should think in terms of:
text
Reservationnot:
text
Reservation + SAP client number18. Expose the UUID as the CDS key
Use:
abap
key Reservation.uuid as Uuid,The table key contains:
text
client + uuidbut the business-object entity key exposed to normal consumers is:
text
UuidThe current client is handled implicitly.
19. Expose the business fields
Add:
abap
Reservation.reservation_no as ReservationNo,
Reservation.customer_name as CustomerName,
Reservation.customer_email as CustomerEmail,
Reservation.workshop_code as WorkshopCode,
Reservation.reservation_date as ReservationDate,
Reservation.status as Status,These aliases create a cleaner CDS vocabulary.
Compare:
text
Database field CDS element
reservation_no → ReservationNo
customer_name → CustomerName
workshop_code → WorkshopCode20. Preserve Fee semantics
The table already expresses:
text
Fee
→ Currency CodeThe root CDS must also make the relationship explicit.
Use:
abap
@Semantics.amount.currencyCode: 'CurrencyCode'
Reservation.fee as Fee,
Reservation.currency_code as CurrencyCode,A monetary value without its currency context is incomplete business information.
21. Expose Notes
Add:
abap
Reservation.notes as Notes,At this stage it is simply another business property.
Later behavior can control how fields may be modified.
22. Administrative fields need semantic meaning
The persistence contains five RAP-ready fields:
text
local_created_by
local_created_at
local_last_changed_by
local_last_changed_at
last_changed_atToday we expose them with semantic annotations.
These annotations tell RAP/framework consumers what each field represents.
23. Created-by field
Use:
abap
@Semantics.user.createdBy: true
Reservation.local_created_by as LocalCreatedBy,This field represents the user that created the instance.
24. Created-at field
Use:
abap
@Semantics.systemDateTime.createdAt: true
Reservation.local_created_at as LocalCreatedAt,This field represents the creation timestamp.
25. Local last-changed user
Use:
abap
@Semantics.user.localInstanceLastChangedBy: true
Reservation.local_last_changed_by as LocalLastChangedBy,This identifies the user responsible for the latest local-instance change.
26. Local last-changed timestamp
Use:
abap
@Semantics.systemDateTime.localInstanceLastChangedAt: true
Reservation.local_last_changed_at as LocalLastChangedAt,This field becomes especially important later.
It can be used as the entity's:
text
ETagfor optimistic concurrency control.
We will configure that in Lesson 11.
27. Total last-changed timestamp
Use:
abap
@Semantics.systemDateTime.lastChangedAt: true
Reservation.last_changed_at as LastChangedAtThis represents the last change to the instance or its compositional subtree. Our current root has no children, so the distinction from the local timestamp becomes useful later.
It becomes especially relevant in more advanced scenarios such as draft and composed Business Objects.
Today, recognize its semantic role.
28. Complete root CDS
Your final source should look like:
abap
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Reservation'
define root view entity ZR_Reservation_###
as select from zresv_### as Reservation
{
key Reservation.uuid as Uuid,
Reservation.reservation_no as ReservationNo,
Reservation.customer_name as CustomerName,
Reservation.customer_email as CustomerEmail,
Reservation.workshop_code as WorkshopCode,
Reservation.reservation_date as ReservationDate,
Reservation.status as Status,
@Semantics.amount.currencyCode: 'CurrencyCode'
Reservation.fee as Fee,
Reservation.currency_code as CurrencyCode,
Reservation.notes as Notes,
@Semantics.user.createdBy: true
Reservation.local_created_by as LocalCreatedBy,
@Semantics.systemDateTime.createdAt: true
Reservation.local_created_at as LocalCreatedAt,
@Semantics.user.localInstanceLastChangedBy: true
Reservation.local_last_changed_by as LocalLastChangedBy,
@Semantics.systemDateTime.localInstanceLastChangedAt: true
Reservation.local_last_changed_at as LocalLastChangedAt,
@Semantics.systemDateTime.lastChangedAt: true
Reservation.last_changed_at as LastChangedAt
}Replace every ###.
29. Syntax check and activate
Use:
text
Ctrl+F2for syntax check.
Then:
text
Ctrl+F3to activate.
If activation fails, inspect the exact ADT error before changing code.
30. Preview the root entity
Run CDS Data Preview:
text
F8Depending on whether you cleaned up Lesson 9 data, the result may be:
text
0 rowsThat is fine.
Use Data Preview to inspect:
text
fields
aliases
key
shapeInspect the CDS source and syntax-check results separately for amount/currency and administrative semantics. Data Preview does not prove that RAP maintains those fields or supports write operations.
31. Compare table and root CDS
Persistence:
text
ZRESV_###contains technical storage names such as:
text
uuid
reservation_no
customer_nameThe root entity exposes business-facing CDS names such as:
text
Uuid
ReservationNo
CustomerNameArchitecture:
text
Persistence Table
↓
RAP Root CDSThe root entity is the business-object data model.
The table is physical persistence.
32. Why keep the UUID?
The UUID remains the technical entity identity.
It gives the future BO:
text
stable technical key
consumer-independent identity
managed-numbering potentialThe human-readable:
text
ReservationNoremains a business property.
Do not replace one with the other.
33. What does the root entity allow us to do now?
By itself, the CDS root can be:
text
activated
previewed
queried
used as the structural basis for RAP behaviorBut we have not yet declared:
text
create
update
delete
locking
ETag
authorization behavior
managed UUID numbering
field characteristics
persistence mappingSo the transactional contract is still missing.
34. Why not put behavior into CDS annotations?
RAP deliberately separates:
text
data structurefrom:
text
transactional behaviorThe root CDS says:
text
what the entity looks likeThe Behavior Definition will say:
text
what can happen to itThis separation is central to RAP.
35. Managed vs unmanaged RAP — concept only
When we create the Behavior Definition, RAP asks how much generic transactional work the framework should provide.
Two major implementation types are:
text
managed
unmanagedToday, understand the difference conceptually.
Do not create the Behavior Definition yet.
36. Managed RAP
In a managed RAP Business Object, the RAP provider handles standard transactional mechanics for normal persistence scenarios.
Depending on the model, managed RAP can provide standardized handling for:
text
transactional buffer
create
update
delete
save processing
locking
managed numbering
administrative fieldsYou still define the business contract.
You can still implement custom business logic.
37. Unmanaged RAP
In unmanaged RAP, the application implements much more of the transactional behavior itself.
Typical reasons include:
text
existing save logic
legacy APIs
special persistence
existing business frameworks
brownfield scenariosUnmanaged does not mean:
text
better
more modern
more advancedIt means the implementation responsibility is different.
38. Which one fits our Reservation scenario?
Our Reservation persistence is:
text
new
simple
owned by us
normal database persistence
UUID-based
prepared for RAPSo our first implementation will use:
text
managed RAPThis is the natural greenfield model for this course scenario.
39. Do not confuse managed RAP with managed database tables
The word:
text
manageddescribes the RAP behavior implementation model.
It does not mean:
text
the database table is a different kind of tableOur persistence remains:
text
ZRESV_###The RAP managed provider will later work with it through the BO behavior contract.
40. Why we stop before the Behavior Definition
It would be possible to create the root CDS and Behavior Definition in the same lesson.
We deliberately do not.
Today's mental model is:
text
Persistence
↓
Root CDSYou should be able to explain this layer cleanly before adding:
text
Behavior Definition
Behavior Pool
locking
ETag
mapping
numberingLesson 11 adds those concepts.
41. Architecture at the end of Lesson 10
You now have:
text
ZRESV_###
↓
ZR_RESERVATION_###Interpret it as:
text
physical persistence
↓
RAP BO data model / root structureYou do not yet have:
text
complete transactional behavior42. Preview of Lesson 11
Lesson 11 will add:
text
ZR_RESERVATION_###
↓
Managed Behavior Definition
↓
Behavior PoolThe Behavior Definition will introduce concepts such as:
text
managed
strict ( 2 )
persistent table
alias
create
update
delete
managed UUID numbering
readonly fields
mapping
lock master
authorization baseline
etag masterDo not implement them yet.
43. Knowledge check
1. What is the difference between persistence and a RAP root entity?
2. What are the two major parts of a RAP Business Object?
3. What does root describe?
4. Can a one-node BO still have a root?
5. Why is client not exposed as an ordinary BO field?
6. Why is Uuid the CDS key?
7. Why does Fee need Currency Code semantics?
8. What is the role of LocalLastChangedAt?
9. What is the high-level difference between managed and unmanaged RAP?
10. Why are we not creating the Behavior Definition today?
44. Teacher-led completion checklist
45. End-of-day mental model
Before leaving Lesson 10, you should be able to draw:
text
ZRESV_###
↓
ZR_RESERVATION_###and explain:
text
ZRESV_###
=
stored Reservation state
ZR_RESERVATION_###
=
RAP Business Object root data modelThen add one blank box underneath:
text
ZRESV_###
↓
ZR_RESERVATION_###
↓
[ Behavior Definition ]That blank box is Lesson 11.