Beyond ABAPdesigned by@Tejoram97
Beyond ABAP / RAP / Data Model & CDS

Data Model & CDS

RAP · ABAP Development ·

Open the interactive lesson →
  1. Requirements, development setup and the build path
  2. Modern ABAP syntax you meet in RAP code
  3. Data model: domains, data elements and tables (R1)
  4. Administrative fields and demo data
  5. CDS view entities: root, child and composition (R1)
  6. VDM naming and key annotations in the base view
  7. Interview questions

This page builds the foundation of the Sales Order Approval app: the system and package, the order in which RAP objects are created, the two tables and their administrative fields, and the CDS root and child view entities that turn header and items into one business object. It implements R1 (an order with several items) and prepares the fields that R2, R3, R9 and R10 need later.

Part 1 – Requirements, development setup and the build path

Before the first line of RAP you need three things: a tool (Eclipse with ADT), a system that speaks ABAP Cloud, and a package for the objects. Then you build in a fixed order, like a house: foundation (tables), walls (CDS), wiring (behavior), and only then the front door (service and app).

1.1 Requirements on this page

R-ID

Requirement

Where on this page

R1

Reps create an order with several items, edit and delete it

Part 3 (tables), Part 5 (root, child, composition)

R3

A rep sees only orders of their sales organisation

Part 3: field sales_org (the DCL itself → 03 · Projection, UI, Access Control & Service)

R2, R4

Status N / A / R with a colour

Part 3 (domain), Part 5 (StatusCriticality)

R9, R10

Readable order number; no overwriting

Part 3 (UUID key + sales_order_id), Part 4 (admin fields)

From requirement to data model: R1 two tables and a composition, R6 association to I_Customer, R5 amount and currency fields, R2 and R4 status domain and StatusCriticality, R3 sales_org field, R9 UUID key plus sales_order_id, R10 admin fields as ETags

1.2 Tool and system

Development setup: ADT in Eclipse connects to an SAP Business AI Platform, ABAP environment, S/4HANA Cloud Public Edition or S/4HANA 2022+ on-premise; package tree of the sales order example; what the ABAP for Cloud Development language version allows and forbids

System

When you use it

What to know

SAP Business AI Platform, ABAP environment – trial

Learning, RAP100 tutorials

Free, shared system, ABAP Cloud only; create your package under ZLOCAL; master data from the /DMO/ flight model. Trial terms change – check SAP's current trial page

SAP Business AI Platform, ABAP environment – productive

Side-by-side extensions, own apps

Own system per customer; managed in the Landscape Portal (software components, hibernation to save cost, updates)

S/4HANA Cloud Public Edition

Developer extensibility in the ERP

ABAP Cloud only; released SAP views such as I_Customer; roles via IAM apps

S/4HANA 2022+ private cloud / on-premise

Greenfield S/4 projects

Classic ABAP and ABAP Cloud side by side; set the language version ABAP for Cloud Development on the package or objects. RAP exists since 1909; draft and most features came later – check your release

  • ADT: Eclipse plus the ADT plug-in from tools.hana.ondemand.com. Cloud systems: *File → New → ABAP Cloud Project* (service key or system URL). On-premise: *ABAP Project* from the SAP GUI logon entry.
  • Developer user in a productive ABAP environment system: an administrator creates the business user (Fiori app *Maintain Business Users*) and assigns a business role built from the template SAP_BR_DEVELOPER.
  • Package: transportable ZSALES with sub-package ZSALES_RAP in projects; a ZLOCAL sub-package (not transportable) in the trial.
  • ABAP for Cloud Development: only released APIs (*Properties → API State*: *Released for ABAP Cloud*), no dynpro, no WRITE lists, no direct SELECT on SAP tables such as KNA1. Violations are syntax errors ("Use of … is not permitted"), not warnings – look for the released successor, e.g. cl_abap_context_info instead of sy-uname.
  • BTP system not reachable in the morning: productive systems can be hibernated in the Landscape Portal and must be resumed first.

1.3 The build path

Build path: dictionary types, tables and demo data, base CDS, base BDEF, behavior pool, projection, metadata extension, projection BDEF, service definition, service binding; each card tagged with the page that explains it and the requirement it serves; cards 3 to 10 created by the ADT generator; DCL and roles added by hand

#

Object (ADT type)

Sales order name

Explained on

1

Domain, data element

ZDO_SO_STATUS, ZDE_SO_ID …

this page, Part 3

2

Database tables + demo data class

zsales_hdr, zsales_itm, zcl_sales_demo_data

this page, Part 3–4

3

Base CDS view entities (root, child)

ZR_SalesOrder, ZR_SalesOrderItem

this page, Part 5

4

Base behavior definition + draft tables

ZR_SalesOrder, zsales_hdr_d, zsales_itm_d

04, 07

5

Behavior pool

ZBP_R_SalesOrder

04

6

Projection views

ZC_SalesOrder, ZC_SalesOrderItem

03

7

Metadata extensions

ZC_SalesOrder, ZC_SalesOrderItem

03

8

Projection behavior definition

ZC_SalesOrder

04

9

Service definition

ZUI_SalesOrder

03

10

Service binding (OData V4 – UI)

ZUI_SalesOrder_O4

03

+

Access control, authorization object, IAM app / PFCG role

ZR_SALESORDER, ZAO_SO

03, 06

  • Activation order: root and child CDS together (they point at each other) → projection → base BDEF → projection BDEF → service definition → binding. ADT's *Activate All* (Ctrl+Shift+F3) handles the cycles.

1.4 Generator or by hand?

ADT can create objects 3 to 10 for you: right-click a table → Generate ABAP Repository Objects… → OData UI Service. You get a managed, draft-enabled BO with UUID keys, the projection, a metadata extension with a basic layout, the behavior pool, the draft tables, service definition and binding.

By hand

ADT generator

Best for

Learning: you see why every object exists

Projects: consistent names, minutes instead of hours

Input

Nothing – you write every object

A table (newer releases: also views, or a wizard from scratch that creates the table too)

Result

Exactly what you typed

Managed + draft + UUID keys + admin fields expected; then you add validations, actions and access control

Availability

Every release with RAP

SAP Business AI Platform, ABAP environment and S/4HANA Cloud; on-premise in newer releases – check your release

  • Newer ADT versions offer the wizard OData UI Service from Scratch, optionally driven by Joule (licence needed, SAP Note 3571857), and SAP publishes XCO generation APIs for generating objects from ABAP code – check your release. The community RAP Generator (SAP-samples/cloud-abap-rap) is an older alternative.
  • Interview tip: "I built the Sales Order BO by hand once, so I can debug and extend what the generator produces."

Part 2 – Modern ABAP syntax you meet in RAP code

RAP handlers work on internal tables of derived types, so 7.40+ expressions are everywhere. One line each, with Sales Order examples (the RAP-specific components %tky, %cid, %control are explained on 08 · EML):

Construct

Example

Means

Inline declaration

DATA(orders) = VALUE tt_orders( ).

Declare where first used

VALUE #

failed-salesorder = VALUE #( ( %tky = order-%tky ) ).

Build a structure or table

CORRESPONDING #

DATA(keys) = CORRESPONDING #( orders ).

Copy same-named fields

COND #

COND #( WHEN o-Status = 'A' THEN 3 ELSE 2 )

if / else as an expression

SWITCH #

SWITCH #( o-Status WHEN 'A' THEN 'Approved' WHEN 'R' THEN 'Rejected' )

case as an expression

CONV

CONV zde_item_no( max_item_no + 10 )

Type conversion inline

REDUCE

REDUCE #( INIT s = CONV decfloat34( 0 ) FOR i IN items NEXT s = s + i-NetPrice * i-Quantity )

Fold a table into one value (R5)

FOR in VALUE

VALUE #( FOR o IN orders ( %tky = o-%tky Status = 'A' ) )

Loop inside an expression

Table expression

DATA(first) = orders[ 1 ]. / orders[ KEY id %tky = key-%tky ]

Read one row (raises CX_SY_ITAB_LINE_NOT_FOUND if missing)

LOOP … GROUP BY

LOOP AT items INTO DATA(i) GROUP BY i-ParentUUID …

Group rows, e.g. totals per order

line_exists( )

IF line_exists( orders[ Status = 'N' ] ).

Check without a read

  • Common mistake: REDUCE #( INIT s = 0 …) – s becomes an integer and the decimals of the amount are lost. Give INIT the right type, as above.

Part 3 – Data model: domains, data elements and tables (R1)

R1 says an order has several items. That is two tables: one row per order in zsales_hdr, one row per item in zsales_itm, linked by the parent key. A few extra fields serve later requirements, so add them now – every later object (CDS, BDEF, draft table) copies the field list.

Data model: tables zsales_hdr and zsales_itm with keys, parent link parent_uuid = order_uuid (1 : 0..*), sales_org for R3, currency and unit reference fields, admin fields with abp data elements, CDS names per field, and the status chain table field → data element → domain

3.1 Design decisions

Decision

Choice in the example

Why (requirement)

Primary key

order_uuid / item_uuid, type sysuuid_x16

RAP draws UUIDs itself (managed numbering) – no number range needed for the key (R1)

Readable number

sales_order_id, CHAR 10 (holds SO-0000001)

Users need a number to talk about; it gets its gap-free value when the order is saved (R9 → 06 · Feature Control, Authorization & Numbering)

Parent link

parent_uuid in the item table

Each item belongs to exactly one order; the CDS composition uses it (R1)

Sales organisation

sales_org on the header

The access control can only filter on a field that exists (R3)

Amounts and quantities

abap.curr + abap.cuky, abap.quan + abap.unit

An amount is meaningless without its currency, a quantity without its unit (R5, R6)

Admin fields

5 on the header, 1 on the item, abp_* data elements

RAP fills them; ETags and draft use them (R10, Part 4)

Master data

Only customer_id, no customer table

Customers live in SAP (I_Customer); the BO only references them (R6)

3.2 Domains and data elements

A domain holds the technical type and the allowed values; a data element gives the business meaning and the field labels, and points to a domain or a built-in type. ADT: New → Other ABAP Repository Object → Dictionary → Domain / Data Element. The labels later appear as column headers in Fiori.

Object

Type

Content

Domain ZDO_SO_STATUS

CHAR 1

Fixed values N New, A Approved, R Rejected (R4, R7)

Data element ZDE_SO_STATUS

Domain ZDO_SO_STATUS

Labels: Status / Order Status

Data element ZDE_SO_ID

CHAR 10

Labels: Sales Order

Data element ZDE_CUSTOMER_ID

CHAR 10

Labels: Customer

Data element ZDE_SALES_ORG

CHAR 4

Labels: Sales Organization

Data element ZDE_MATERIAL_ID

CHAR 40

Labels: Material

Data element ZDE_ITEM_NO

NUMC 6

Labels: Item

  • Reuse released SAP data elements where they exist; create your own when you need your own labels or values.

3.3 The tables

ADT: New → Other → Dictionary → Database Table. Tables are edited as source code. Delivery class A (application data), data maintenance restricted.

@EndUserText.label : 'Sales order header'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zsales_hdr {
key client            : abap.clnt not null;
key order_uuid        : sysuuid_x16 not null;
sales_order_id        : zde_so_id;
customer_id           : zde_customer_id;
sales_org             : zde_sales_org;
order_date            : abap.dats;
status                : zde_so_status;
@Semantics.amount.currencyCode : 'zsales_hdr.currency'
net_amount            : abap.curr(15,2);
currency              : abap.cuky;
created_by            : abp_creation_user;
created_at            : abp_creation_tstmpl;
local_last_changed_by : abp_locinst_lastchange_user;
local_last_changed_at : abp_locinst_lastchange_tstmpl;
last_changed_at       : abp_lastchange_tstmpl;
}
@EndUserText.label : 'Sales order item'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zsales_itm {
key client            : abap.clnt not null;
key item_uuid         : sysuuid_x16 not null;
@AbapCatalog.foreignKey.screenCheck : false
parent_uuid           : sysuuid_x16 not null
with foreign key [0..*,1] zsales_hdr
where client     = zsales_itm.client
and order_uuid = zsales_itm.parent_uuid;
item_no               : zde_item_no;
material_id           : zde_material_id;
@Semantics.quantity.unitOfMeasure : 'zsales_itm.unit'
quantity              : abap.quan(13,3);
unit                  : abap.unit(3);
@Semantics.amount.currencyCode : 'zsales_itm.currency'
net_price             : abap.curr(15,2);
currency              : abap.cuky;
local_last_changed_at : abp_locinst_lastchange_tstmpl;
}
  • The foreign key documents the header–item link in the dictionary. RAP does not need it – the parent-child relation comes from the CDS composition (Part 5).
  • Currency / quantity semantics: a curr field must reference a cuky field and a quan field a unit field. Without the annotation the table does not activate, and Fiori could not show "150.00 EUR" with the right decimals.
  • The draft tables zsales_hdr_d / zsales_itm_d are generated from the BDEF later (→ 07 · Locking, Draft & Side Effects); the extra customer field of R19 goes through an extension include (→ 12 · Extensibility & Testing).
  • Newer option: since SAP Business AI Platform, ABAP environment 2502 a CDS table entity (define table entity) can replace the DDIC table as persistence. Check your release – this page uses classic DDIC tables, which work everywhere.

Part 4 – Administrative fields and demo data

4.1 Administrative fields

Five header fields answer "who created it, who changed it last, and has it changed since I read it?". With the right data elements and CDS annotations a managed BO fills them automatically – you never write code for them. They are the raw material for R10 (no two users overwrite each other).

Admin fields through the life of an order: create by USER_A, change by USER_B, edit in draft (only the draft row changes) and activate; LocalLastChangedAt is the instance ETag, LastChangedAt the total ETag

Field

Data element

CDS annotation

Used for

created_by

abp_creation_user

@Semantics.user.createdBy

Audit

created_at

abp_creation_tstmpl

@Semantics.systemDateTime.createdAt

Audit

local_last_changed_by

abp_locinst_lastchange_user

@Semantics.user.localInstanceLastChangedBy

Audit

local_last_changed_at

abp_locinst_lastchange_tstmpl

@Semantics.systemDateTime.localInstanceLastChangedAt

ETag per instance

last_changed_at

abp_lastchange_tstmpl

@Semantics.systemDateTime.lastChangedAt

Total ETag (draft)

  • LocalLastChangedAt changes with every change of the instance, also in the draft; LastChangedAt on the root changes only when the active data changes. How RAP uses them as ETag and total ETag → 07 · Locking, Draft & Side Effects.
  • Unmanaged BOs fill these fields themselves, e.g. with cl_abap_context_info=>get_user_technical_name( ) and GET TIME STAMP FIELD (→ 09 · Unmanaged Scenario & Save Variants).
  • Common mistake: forgetting the @Semantics annotations in the base view – a managed BO then leaves the admin fields empty and ETag checks do not work.

4.2 Demo data with a console class

In ABAP Cloud there are no reports. A class that implements IF_OO_ADT_CLASSRUN runs in ADT with F9 and writes to the console – the standard way to fill test data.

CLASS zcl_sales_demo_data DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.

CLASS zcl_sales_demo_data IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA headers TYPE STANDARD TABLE OF zsales_hdr WITH EMPTY KEY.
DATA items   TYPE STANDARD TABLE OF zsales_itm WITH EMPTY KEY.
DATA now     TYPE timestampl.

GET TIME STAMP FIELD now.
DATA(user)  = cl_abap_context_info=>get_user_technical_name( ).
DATA(today) = cl_abap_context_info=>get_system_date( ).

TRY.
DATA(order1) = cl_system_uuid=>create_uuid_x16_static( ).
DATA(order2) = cl_system_uuid=>create_uuid_x16_static( ).

headers = VALUE #(
created_by = user  created_at = now  local_last_changed_by = user
local_last_changed_at = now  last_changed_at = now
order_date = today  currency = 'EUR'  sales_org = '1010'
( order_uuid  = order1  sales_order_id = 'SO-0000001'
customer_id = '0010100001'  status = 'N'  net_amount = '150.00' )
( order_uuid  = order2  sales_order_id = 'SO-0000002'
customer_id = '0010100002'  status = 'A'  net_amount = '80.00' ) ).

items = VALUE #(
currency = 'EUR'  unit = 'ST'  local_last_changed_at = now
( item_uuid   = cl_system_uuid=>create_uuid_x16_static( )
parent_uuid = order1  item_no = '000010'  material_id = 'MAT-001'
quantity    = 10  net_price = '15.00' )
( item_uuid   = cl_system_uuid=>create_uuid_x16_static( )
parent_uuid = order2  item_no = '000010'  material_id = 'MAT-002'
quantity    = 4  net_price = '20.00' ) ).
CATCH cx_uuid_error INTO DATA(error).
out->write( error->get_text( ) ).
RETURN.
ENDTRY.

DELETE FROM zsales_itm.                        " demo only: start from empty tables
DELETE FROM zsales_hdr.
INSERT zsales_hdr FROM TABLE @headers.
INSERT zsales_itm FROM TABLE @items.
out->write( |{ lines( headers ) } orders and { lines( items ) } items inserted| ).
ENDMETHOD.
ENDCLASS.
  • unit = 'ST' is the internal code of the unit "piece" (shown as PC in English). Use customer numbers and a sales organisation that exist in your system, otherwise validateCustomer (R6) rejects the orders and the access control (R3) hides them.
  • Direct INSERT bypasses the BO – fine for demo data, never in application code. Once the BO exists, a better demo class creates orders with MODIFY ENTITIES … CREATE + COMMIT ENTITIES, so determinations and validations run too (→ 08 · EML, R12).
  • Preview is empty later? Either the tables have no data (run this class) or the access control filters every row (→ 03 · Projection, UI, Access Control & Service).

Part 5 – CDS view entities: root, child and composition (R1)

Tables store data; CDS view entities give it business names, relationships and meaning. The base views (ZR_) form the tree of the business object – a root for the order and a child for its items – and everything else in RAP (behavior, projection, EML, OData) is built on them. The composition is how R1 ("an order with several items") becomes one business object.

BO composition tree: root ZR_SalesOrder and child ZR_SalesOrderItem inside the BO boundary, linked by composition _Item and to-parent _SalesOrder; associations _Customer and _Currency leave the BO to released SAP views

5.1 The root and child view entities

ADT: right-click the table → New Data Definition → template *Define Root View Entity* for the header, *Define View Entity* for the item. The CDS names (CamelCase) are what RAP, EML and OData use from now on.

@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales order'
@ObjectModel.semanticKey: [ 'SalesOrderID' ]
define root view entity ZR_SalesOrder
as select from zsales_hdr
composition [0..*] of ZR_SalesOrderItem as _Item
association [0..1] to I_Customer        as _Customer
on $projection.CustomerID = _Customer.Customer
association [0..1] to I_Currency        as _Currency
on $projection.Currency = _Currency.Currency
{
key order_uuid            as OrderUUID,
sales_order_id        as SalesOrderID,
customer_id           as CustomerID,
sales_org             as SalesOrganization,
order_date            as OrderDate,
status                as Status,
case status when 'A' then 3                      // green
when 'R' then 1                      // red
when 'N' then 2                      // orange
else 0 end as StatusCriticality,     // calculated, not in the table
@Semantics.amount.currencyCode: 'Currency'
net_amount            as NetAmount,
currency              as Currency,
@Semantics.user.createdBy: true
created_by            as CreatedBy,
@Semantics.systemDateTime.createdAt: true
created_at            as CreatedAt,
@Semantics.user.localInstanceLastChangedBy: true
local_last_changed_by as LocalLastChangedBy,
@Semantics.systemDateTime.localInstanceLastChangedAt: true
local_last_changed_at as LocalLastChangedAt,
@Semantics.systemDateTime.lastChangedAt: true
last_changed_at       as LastChangedAt,
_Item,
_Customer,
_Currency
}
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales order item'
define view entity ZR_SalesOrderItem
as select from zsales_itm
association to parent ZR_SalesOrder as _SalesOrder
on $projection.ParentUUID = _SalesOrder.OrderUUID
{
key item_uuid             as ItemUUID,
parent_uuid           as ParentUUID,
item_no               as ItemNo,
material_id           as MaterialID,
@Semantics.quantity.unitOfMeasure: 'Unit'
quantity              as Quantity,
unit                  as Unit,
@Semantics.amount.currencyCode: 'Currency'
net_price             as NetPrice,
currency              as Currency,
@Semantics.systemDateTime.localInstanceLastChangedAt: true
local_last_changed_at as LocalLastChangedAt,
_SalesOrder
}
  • Activation: create both, then activate them together (they refer to each other).
  • Master data comes from released SAP views: I_Customer in S/4HANA. In the BTP trial use the flight model's /DMO/I_Customer instead.
  • StatusCriticality (R2) is a calculated element: Fiori uses it for the status colour (→ 03 · Projection, UI, Access Control & Service). It is not in the table, so the BDEF marks it read-only (→ 04 · Behavior Definition & Behavior Pool).

5.2 Root, child, composition, association

Association

Composition

Relationship

Loose link ("uses")

Whole–part ("consists of")

Cardinality

Any: [0..1], [1], [0..*]

[0..*] or [0..1] to children; the child has one parent

Child exists without parent?

Yes (SalesOrder → Customer)

No (an item only inside its order)

Delete parent

Target stays

Children deleted too (R1: delete an order)

Locking / ETag / auth

Independent

Children follow the parent (lock / authorization dependent)

CDS syntax

association [0..1] to …

composition [0..*] of … + association to parent …

Navigation

_Customer.CustomerName in a path

_Item from header to items, _SalesOrder back

In the BDEF

Nothing needed (read-only)

association _Item { create; } → create by association (→ 04)

  • Root: the top entity, define root view entity, exactly one per BO. Child: an entity reached by composition. Leaf: a child with no children of its own (here the item is both child and leaf).
  • 1:1 vs 1:n: [0..1] = at most one target (customer of an order), [0..*] = many (items of an order).
  • Common mistake: modelling master data (customer, material) as a composition. They have their own lifecycle – use an association.
  • Common mistake: forgetting association to parent in the child – the composition does not activate.

Part 6 – VDM naming and key annotations in the base view

SAP's Virtual Data Model (VDM) gives each view a prefix that says its job. Following it makes your BO look like SAP's own and tells every reader where to put which annotation.

VDM layers: metadata extension (UI annotations), C_ projection (search, value help, text), R_ base BO (semantics, semantic key, access control), database tables; VDM prefixes R_, C_, I_, P_, A_, E_; CDS view entity vs obsolete DDIC-based view

6.1 VDM prefixes

Prefix

Meaning

Sales order example

R_

Restricted reuse view – the base BO the BDEF sits on

ZR_SalesOrder

C_

Consumption view – projection for one app or API

ZC_SalesOrder, ZC_SalesOrderApv

I_

Interface view – stable, often released for reuse; also BO interfaces

ZI_SalesOrderTP, ZI_CustomerVH

P_

Private helper view, not for direct use

–

A_

Remote API view (published OData APIs)

–

E_

Extension include view for customer fields

–

  • SAP's released transactional BOs end in TP (transactional processing), e.g. I_SalesOrderTP (used for R18 → 11 · Files, Custom Entities & Integration). Older tutorials used ZI_ for the base view; the ADT generator and current guidelines use ZR_.
  • Always create CDS view entities (define view entity). DDIC-based views (define view + @AbapCatalog.sqlViewName) are obsolete, create an extra SQL view and cannot be created in ABAP for Cloud Development.

6.2 Key annotations in the base view

Annotation

Effect

Example

@AccessControl.authorizationCheck

#CHECK: an access control is expected (warning if missing); #NOT_REQUIRED, #NOT_ALLOWED, #PRIVILEGED_ONLY; newer #MANDATORY (check your release)

#CHECK (R3)

@EndUserText.label

Description of the view and default label

'Sales order'

@ObjectModel.semanticKey

The human key: shown bold in Fiori, used in draft messages

[ 'SalesOrderID' ]

@Semantics.amount.currencyCode

Amount ↔ currency field

NetAmount → Currency

@Semantics.quantity.unitOfMeasure

Quantity ↔ unit field

Quantity → Unit

@Semantics.user.*, @Semantics.systemDateTime.*

Admin fields filled by managed RAP

CreatedBy, LastChangedAt

@ObjectModel.text.element

Which element holds the text for a code

CustomerID → CustomerName

@Semantics.text: true

Marks an element as a text (in value help or text views)

CustomerName

@Metadata.allowExtensions: true

Allows a metadata extension (usually on the projection)

ZC_SalesOrder

  • Rule of thumb: meaning of the data (semantics, keys, access control) goes in the base view; anything a specific app needs (search, value help, UI) goes in the projection or metadata extension (→ 03 · Projection, UI, Access Control & Service).

Part 7 – Interview questions

Q1. How do you start a RAP project – generator or by hand?

For a standard managed BO on new tables I let the ADT generator ("Generate ABAP Repository Objects → OData UI Service" or the wizard from scratch) create the stack, then adapt names, annotations and behavior. I build by hand when I wrap existing tables or logic, or when the generated structure doesn't fit. Either way I must understand every object, because I maintain it afterwards.

Q2. Which administrative fields does a RAP table need and why?

CreatedBy/CreatedAt, LocalLastChangedBy/LocalLastChangedAt and LastChangedAt, typed with the abp_* data elements and annotated with @Semantics.user.* / @Semantics.systemDateTime.*. A managed BO fills them automatically; LocalLastChangedAt is the ETag of the instance and LastChangedAt the total ETag that draft uses to detect changes to the active data.

Q3. Composition vs association?

A composition is a whole–part relation: the item cannot exist without its order, is created through it, locked via it and deleted with it, and the compositions define the BO tree. An association is a loose link to independent data such as the customer. Each composition child needs association to parent back to its parent.

Q4. Why a UUID key and a separate order number?

The UUID is drawn by the framework the moment an order is created, so the key never depends on a number range and works for drafts. The readable number SO-0000001 is a separate field (the semantic key) that can be assigned gap-free at save time with late numbering. Users see the number, RAP works with the UUID.

Q5. What do root, child and leaf mean, and what must exist for a composition to activate?

The root is the top entity (define root view entity, one per BO), a child is reached by composition, a leaf is a child without children. The root declares composition [0..*] of the child, the child declares association to parent with the ON condition on the parent key, and both are activated together.

Q6. Why CDS view entities and not DDIC-based CDS views?

DDIC-based views (define view with @AbapCatalog.sqlViewName) are obsolete: they create an extra SQL view in the dictionary, activate more slowly and cannot be created in ABAP for Cloud Development. View entities are the current CDS object type and what RAP BOs are built on.

Q7. How do you fill test data in ABAP Cloud without reports?

With a console class that implements if_oo_adt_classrun and runs with F9 in ADT. For a quick start it inserts directly into the tables; once the BO exists, I create the data with MODIFY ENTITIES and COMMIT ENTITIES, so determinations and validations run as in the app.

Q8. Which annotations belong in the base view and which in the projection?

The base view (ZR_) carries what is true for every consumer: semantic key, currency and unit references, admin field semantics, text relations and the access control check. The projection and its metadata extension carry what one app needs: search, value help, UI layout and labels. That keeps the base BO reusable for several apps and APIs.

🏠 Start Here · ◀ 01 · Foundations · 03 · Projection & Service ▶ · Sections: CORE ABAP | OOPS ABAP | ABAP on HANA | Clean Core | RAP | ABAP Points | SAP Fiori | SAPUI5 | Mobile Development (MDK) | BTP Foundations | BTP Development | CAP | SAP Build | ABAP on BTP | Integration Suite | SAP Business AI | SAP BASIS | Security | SAP SDLC

Functional: FICO ABAP | TRM ABAP | VIM | SAP BIS | SD ABAP | MM ABAP | PP ABAP | QM ABAP | PM ABAP | PS ABAP | EWM | TM ABAP | EHS ABAP | HR ABAP | BW | SAP MDG | SAP Analytics Cloud | SAP Ariba | SAP CX | SAP IBP