Skip to content

Lesson 8 Companion — Custom Persistence Modeling ​

This companion expands Lesson 8 — Custom Persistence Modeling.

The teacher-led lesson intentionally stops after:

text
Domain
  ↓
Data Element
  ↓
Database Table
  ↓
Activation / Data Preview

No direct database writes are required today.

That split is deliberate so the afternoon Practice tests only persistence-modeling skills.


1. Why this lesson exists before RAP ​

SAP's current RAP development flow begins with persistence and data modeling before behavior.

The course follows that logic:

text
Lesson 8
Persistence model

Lesson 9
Direct persistence mechanics

Lesson 10
RAP BO structure

Lesson 11
Managed behavior

Lesson 12
EML

Students first understand what the framework will sit on top of.


2. Why define table is still taught ​

Current ABAP Cloud also supports:

abap
define table entity

CDS Table Entities are an important newer persistence model.

However, current SAP learning content still explicitly teaches source-based ABAP Dictionary tables using:

abap
define table

together with:

text
Domains
Data Elements
client fields
primary keys
table annotations

This remains useful certification knowledge.


3. define table vs define table entity ​

High-level comparison:

Source-based DDIC tableCDS Table Entity
Definitiondefine tabledefine table entity
PersistentYesYes
ABAP SQL source/targetYesYes
Can be RAP active persistenceYesYes
Domain/Data Element-centric teachingYesDifferent CDS-native model
Hands-on in this course todayYesNo

Do not try to learn both persistence models simultaneously in the first custom-table exercise.


4. Dictionary DDL vs CDS DDL ​

These syntaxes look related but represent different object families.

abap
define table ...

is source-based ABAP Dictionary DDL.

abap
define view entity ...

is ABAP CDS DDL for a query/model entity.

abap
define table entity ...

is ABAP CDS DDL for a persistent table entity.

The keyword tells you what kind of artifact you are creating.


5. Row grain ​

A reliable database design begins with a sentence:

text
One row represents ...

Reservation:

text
One row represents one workshop reservation.

Support Issue Practice:

text
One row represents one support issue.

If the sentence is unclear, the key and field design are usually unclear too.


6. Technical identity vs business identity ​

The course uses:

text
UUID

as technical identity.

It separately stores:

text
ReservationNo
IssueNo

as business-facing identifiers.

This avoids coupling persistence identity to future business numbering.


7. UUID choice ​

The persistence key uses:

text
SYSUUID_X16

which represents a RAW(16) UUID.

This choice prepares the table for later managed RAP UUID numbering.

In Lesson 9, students will also generate a UUID directly in ABAP so they can understand the low-level mechanism.


8. Domain role ​

A Domain defines technical characteristics such as:

text
type
length
decimal places
value range

Reservation Status:

text
ZDM_RSTAT_###
CHAR(1)
N/C/X

Support Issue Status:

text
ZDM_ISTAT_###
CHAR(1)
O/I/C

9. Fixed-value nuance ​

Domain fixed values are valuable metadata.

They can support framework behavior and input assistance.

They should not be described as:

an unconditional database CHECK constraint that implements all business rules.

Future RAP behavior still needs validations for transactional rules.


10. Data Element role ​

A Data Element connects technical typing with reusable business semantics.

It can provide:

text
Domain-based type
field labels
developer description
reusable field meaning

A Domain itself is not the business field type used in the table.


11. SAP recommendation for business fields ​

SAP's current data-modeling learning material recommends Data Elements for business fields so semantic metadata and labels are reusable.

The course intentionally creates only one custom Data Element in the guided scenario to avoid spending most of the day creating near-identical repository objects.

Production modeling can go further.


12. Client handling ​

The pattern:

abap
key client : abap.clnt not null;

makes the normal application table client-dependent.

For standard ABAP SQL access, the current client is handled implicitly.

That is why later code will not normally write:

abap
WHERE client = @sy-mandt

for every access.

Client handling is data isolation, not authorization.


13. Primary-key order ​

For the course tables:

text
client
uuid

are the key fields and appear at the beginning of the field list.

This gives a client-dependent technical key.


14. NOT NULL ​

NOT NULL prevents SQL NULL.

It does not mean:

text
not blank
not zero
business mandatory

For example:

text
CHAR(10) initial value

is still a value from the ABAP perspective.

Later RAP field characteristics and validations can model business-required fields.


15. Table annotations reference ​

Guided table:

abap
@EndUserText.label : 'Workshop Reservations'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED

Key teaching points:

text
normal transparent table
application data
restricted generic maintenance
not extensible for this exercise

16. Amount/currency semantics ​

Current SAP examples use a qualified field reference at table level:

abap
@Semantics.amount.currencyCode : 'zresv_###.currency_code'
fee : abap.curr(10,2);

The Support Issue table uses the same pattern:

abap
@Semantics.amount.currencyCode : 'zissue_###.currency_code'
estimated_cost : abap.curr(10,2);

This metadata matters because a numeric amount without its currency is incomplete business information.


17. RAP reuse Data Elements ​

The table includes:

text
ABP_CREATION_USER
ABP_CREATION_TSTMPL
ABP_LOCINST_LASTCHANGE_USER
ABP_LOCINST_LASTCHANGE_TSTMPL
ABP_LASTCHANGE_TSTMPL

These are standard RAP-oriented reuse types.

Field names used in the course:

text
local_created_by
local_created_at
local_last_changed_by
local_last_changed_at
last_changed_at

18. Local vs total last changed ​

Local ​

text
local_last_changed_at

will later support a local ETag.

Total ​

text
last_changed_at

will later matter for total-ETag/draft scenarios.

Keeping both now avoids a persistence redesign later.


19. Full guided Domain reference ​

Create:

text
ZDM_RSTAT_###

Properties:

text
Type:   CHAR
Length: 1

Fixed values:

ValueDescription
NNew
CConfirmed
XCancelled

20. Full guided Data Element reference ​

Create:

text
ZDE_RSTAT_###

Domain:

text
ZDM_RSTAT_###

Suggested labels:

text
Short:   Status
Medium:  Reservation Status
Long:    Reservation Status
Heading: Status

21. Full guided table reference ​

abap
@EndUserText.label : 'Workshop Reservations'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zresv_### {

  key client                : abap.clnt not null;
  key uuid                  : sysuuid_x16 not null;

  reservation_no            : abap.numc(8) not null;
  customer_name             : abap.char(60) not null;
  customer_email            : abap.char(100);
  workshop_code             : abap.char(10) not null;
  reservation_date          : abap.dats not null;
  status                    : zde_rstat_### not null;

  @Semantics.amount.currencyCode : 'zresv_###.currency_code'
  fee                       : abap.curr(10,2);

  currency_code             : abap.cuky;
  notes                     : abap.char(255);

  local_created_by          : abp_creation_user;
  local_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;

}

22. Why the guided table uses built-in types ​

Examples:

abap
customer_name  : abap.char(60);
workshop_code  : abap.char(10);

This is legal and keeps the first persistence exercise manageable.

Students should still know the production recommendation:

text
use reusable Data Elements where business semantics are reusable/valuable

The course deliberately demonstrates that pattern with Status.


23. Data Preview ​

For a Database Table in ADT:

text
Alt + F8

or:

text
Open With → Data Preview

At the end of Lesson 8, zero rows is correct.

The important result is:

text
the table activates
its schema is correct

24. Practice design-review exercise ​

The Practice begins with a deliberately weak design:

abap
define table zissue_### {
  key issue_no      : abap.numc(8);
      status        : abap.char(1);
      estimated_cost: abap.curr(10,2);
      currency_code : abap.cuky;
}

Students should identify problems such as:

text
no client key
no technical UUID
business number used as technical key
status has no reusable Domain/Data Element
no amount/currency semantic relationship
no RAP administrative fields
no explicit NOT NULL decisions
missing normal table annotations

The purpose is not merely to "spot syntax errors."

It tests persistence design reasoning.


25. Practice Domain reference ​

Create:

text
ZDM_ISTAT_###

Type:

text
CHAR(1)

Fixed values:

ValueDescription
OOpen
IIn Progress
CClosed

26. Practice Data Element reference ​

Create:

text
ZDE_ISTAT_###

Domain:

text
ZDM_ISTAT_###

Suggested labels:

text
Short:   Status
Medium:  Issue Status
Long:    Support Issue Status
Heading: Status

27. Full Practice table reference ​

abap
@EndUserText.label : 'Support Issues'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zissue_### {

  key client                : abap.clnt not null;
  key uuid                  : sysuuid_x16 not null;

  issue_no                  : abap.numc(8) not null;
  title                     : abap.char(80) not null;
  description               : abap.char(255);
  requester_email           : abap.char(100);
  priority                  : abap.char(1);
  status                    : zde_istat_### not null;
  reported_on               : abap.dats not null;

  @Semantics.amount.currencyCode : 'zissue_###.currency_code'
  estimated_cost            : abap.curr(10,2);

  currency_code             : abap.cuky;

  local_created_by          : abp_creation_user;
  local_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;

}

28. Why Priority is not another required Domain today ​

A second custom Domain/Data Element would be valid.

It is intentionally optional because the practice goal is:

text
prove you can reproduce the pattern independently

not:

text
maximize repository-object count

Students who finish early can model Priority as a reusable type in the optional challenge.


29. Certification-style reasoning ​

Students should be able to explain without source code:

text
Domain vs Data Element
technical key vs business identifier
client handling vs authorization
SQL NULL vs ABAP initial
amount vs currency
local vs total last change
DDIC table vs CDS view

Those distinctions matter more than memorizing one table definition.


30. Troubleshooting ​

Data Element cannot find Domain ​

Check:

text
Domain activated?
correct suffix?
correct package/object?

Table cannot find custom Data Element ​

Activate:

text
ZDM_...
ZDE_...

before activating the table.

Currency annotation error ​

Check the qualified reference:

text
zresv_###.currency_code

or:

text
zissue_###.currency_code

Table name rejected ​

Check the repository name length.

Data Preview shortcut does not work ​

Use:

text
Open With → Data Preview

instead.


31. Current SAP references ​

Useful current SAP learning/help topics for this lesson:

text
Building Data Models with the ABAP Dictionary and ABAP Core Data Services
  → Creating Database Tables
  → Defining Domains and Data Elements

ABAP Cloud Help
  → Database Tables
  → RAP Reuse Data Elements
  → Creating/Enabling RAP Persistence

The course uses the same core patterns:

text
define table
client key
Data Elements
amount/currency references
RAP administrative fields