Appearance
EML Cheat Sheet — RAP Business Object Consumption
Use this sheet from Lesson 12 onward. Browse all cheat sheets.
Replace ### with your own student/group suffix.
Course examples use:
text
Root BO: ZR_RESERVATION_###
Entity alias: Reservation
Technical key: Uuid1. Mental model
EML stands for Entity Manipulation Language.
Use it to work with a RAP Business Object:
text
ABAP Consumer
↓
EML
↓
RAP Business Object
↓
Transactional Buffer
↓
PersistenceFor normal RAP consumers:
text
EML → BOnot:
text
direct SQL → RAP-owned table2. Quick command map
| Goal | EML |
|---|---|
| Read BO data | READ ENTITIES |
| Create | MODIFY ENTITIES ... CREATE |
| Update | MODIFY ENTITIES ... UPDATE |
| Delete | MODIFY ENTITIES ... DELETE |
| Execute action | MODIFY ENTITIES ... EXECUTE |
| Save transaction | COMMIT ENTITIES |
| Discard transaction | ROLLBACK ENTITIES |
| Inspect features/permissions | GET PERMISSIONS |
| Provider-side BO access | ... IN LOCAL MODE |
External Consumer EML
Normal consumer classes such as:
text
ZCL_RESV_EML_###
ZCL_RESV_RULES_###
ZCL_RESV_ACTIONS_###use normal EML.
Do not add IN LOCAL MODE to an ordinary external consumer.
3. READ — selected fields
abap
READ ENTITIES OF ZR_Reservation_###
ENTITY Reservation
FIELDS (
Uuid
ReservationNo
CustomerName
Status )
WITH VALUE #(
( Uuid = uuid )
)
RESULT DATA(reservations)
FAILED DATA(failed_read).Think:
text
BO → entity → fields → key(s) → result4. READ — all fields
abap
READ ENTITIES OF ZR_Reservation_###
ENTITY Reservation
ALL FIELDS
WITH VALUE #( ( Uuid = uuid ) )
RESULT DATA(reservations)
FAILED DATA(failed_read).Useful for testing and inspecting administrative fields.
Prefer selected fields when you only need a few values.
5. CREATE
abap
MODIFY ENTITIES OF ZR_Reservation_###
ENTITY Reservation
CREATE FIELDS (
ReservationNo
CustomerName
ReservationDate
Fee
CurrencyCode )
WITH VALUE #(
( %cid = 'RES_1'
ReservationNo = '98000001'
CustomerName = 'EML Student'
ReservationDate = cl_abap_context_info=>get_system_date( )
Fee = '150.00'
CurrencyCode = 'EUR' )
)
MAPPED DATA(mapped)
FAILED DATA(failed)
REPORTED DATA(reported).For a managed UUID key, do not provide Uuid yourself.
6. %cid
%cid is the consumer-side temporary identifier for a create request.
abap
%cid = 'RES_1'Think:
text
%cid
↓
MAPPED
↓
generated BO key7. Get the generated UUID from MAPPED
Prefer correlation by %cid:
abap
DATA(uuid) =
mapped-reservation[ %cid = 'RES_1' ]-Uuid.Safer:
abap
IF line_exists(
mapped-reservation[ %cid = 'RES_1' ] ).
DATA(uuid) =
mapped-reservation[ %cid = 'RES_1' ]-Uuid.
ENDIF.Do not rely on mapped-table row order unless you deliberately designed for it.
8. UPDATE
abap
MODIFY ENTITIES OF ZR_Reservation_###
ENTITY Reservation
UPDATE FIELDS (
Status
Notes )
WITH VALUE #(
( Uuid = uuid
Status = 'C'
Notes = 'Updated with EML' )
)
FAILED DATA(failed)
REPORTED DATA(reported).UPDATE FIELDS makes the intended changed fields explicit.
9. DELETE
abap
MODIFY ENTITIES OF ZR_Reservation_###
ENTITY Reservation
DELETE FROM VALUE #(
( Uuid = uuid )
)
FAILED DATA(failed)
REPORTED DATA(reported).Use the BO technical key.
Do not replace normal RAP consumption with direct table DELETE.
10. EXECUTE an action
If the BDEF declares confirm:
abap
MODIFY ENTITIES OF ZR_Reservation_###
ENTITY Reservation
EXECUTE confirm
FROM VALUE #(
( Uuid = uuid )
)
RESULT DATA(action_result)
FAILED DATA(failed)
REPORTED DATA(reported).For an action declared with:
text
result [1] $selfRESULT contains the changed Reservation instance.
RAP Responses
11. MAPPED, FAILED, REPORTED
MAPPED
Key mapping after create/numbering.
Typical use:
text
%cid → generated UuidFAILED
Programmatic failure information.
Think:
text
Which instance failed?REPORTED
Messages and reported information.
Think:
text
Why did it fail?
What should the consumer know?12. FAILED vs REPORTED
text
FAILED
→ this instance/operation failed
REPORTED
→ explanation/message/contextA validation commonly fills both.
A message alone is not the same as marking an instance failed.
13. Inspect responses while learning
abap
out->write( mapped ).
out->write( failed ).
out->write( reported ).In production logic, react to the relevant response instead of only printing it.
RAP Transaction
14. Transactional buffer
text
MODIFY ENTITIES
↓
transactional buffer
↓
READ ENTITIES can see current transaction state
↓
COMMIT or ROLLBACKA successful MODIFY ENTITIES is not the same as a completed save.
15. COMMIT
abap
COMMIT ENTITIES
RESPONSE OF ZR_Reservation_###
FAILED DATA(failed_commit)
REPORTED DATA(reported_commit).Use this to trigger the RAP save sequence and persist successful changes.
Check:
text
FAILED
REPORTED
sy-subrc16. ROLLBACK
abap
ROLLBACK ENTITIES.Use it to discard the current RAP transaction.
Typical test:
text
UPDATE
↓
READ changed buffer state
↓
ROLLBACK ENTITIES
↓
READ original persisted state17. Interaction phase vs save phase
text
MODIFY ENTITIES
→ interaction-phase response
COMMIT ENTITIES
→ save-phase responseImportant pattern:
text
MODIFY create succeeds
↓
instance enters transaction
↓
COMMIT ENTITIES
↓
on-save validation fails
↓
FAILED + REPORTEDSo:
text
successful MODIFY ≠ successful saveSpecial % Components
18. %cid
text
create-request correlation IDUsed heavily with:
text
CREATE
MAPPED19. %tky
text
transactional keyCommon provider-side use:
abap
%tky = reservation-%tkyUse it for the current BO instance identity inside behavior implementation.
20. %param
Used for action/function result parameters.
Example for result [1] $self:
abap
result = VALUE #(
FOR reservation IN reservations
( %tky = reservation-%tky
%param = reservation )
).21. %element
Targets a message at a field.
abap
%element-CustomerName = if_abap_behv=>mk-onThink:
text
this message belongs to CustomerName22. %features
Used in dynamic feature control.
Examples:
text
%features-%action-confirm
%features-%field-FeeRemember:
text
fc-o = operation/action feature
fc-f = field featureProvider-Side EML
Provider-side EML is used inside the Behavior Pool for logic such as:
text
determinations
validations
actions
feature control
authorization handlers23. IN LOCAL MODE
Provider-side read:
abap
READ ENTITIES OF ZR_Reservation_### IN LOCAL MODE
ENTITY Reservation
FIELDS ( Status )
WITH CORRESPONDING #( keys )
RESULT DATA(reservations).Provider-side modify:
abap
MODIFY ENTITIES OF ZR_Reservation_### IN LOCAL MODE
ENTITY Reservation
UPDATE FIELDS ( Status )
WITH updates.Use local mode for BO implementation logic, not as a shortcut in ordinary consumer code.
24. External vs provider-side EML
| Context | Use |
|---|---|
| External consumer class | Normal EML |
| Behavior Pool implementation | EML IN LOCAL MODE |
| External transaction end | COMMIT ENTITIES / ROLLBACK ENTITIES |
| RAP handler method | Do not commit/rollback the transaction |
A handler participates in the RAP transaction; it does not own the external transaction boundary.
BDEF-Derived Types
25. Create request type
abap
DATA creates
TYPE TABLE FOR CREATE ZR_Reservation_###.Example:
abap
creates = VALUE #(
( %cid = 'RES_1'
ReservationNo = '98000001'
CustomerName = 'Student'
ReservationDate = cl_abap_context_info=>get_system_date( )
Fee = '100.00'
CurrencyCode = 'EUR' )
).Pass it with:
text
WITH creates26. Update request type
abap
DATA updates
TYPE TABLE FOR UPDATE ZR_Reservation_###.Example:
abap
updates = VALUE #(
( Uuid = uuid
Status = 'C' )
).27. Permission-derived types
Useful types include:
abap
TYPE TABLE FOR PERMISSIONS KEY
TYPE STRUCTURE FOR PERMISSIONS REQUEST
TYPE STRUCTURE FOR PERMISSIONS RESULTThese are useful for larger or dynamic permission requests.
Feature Control / Permissions
28. GET PERMISSIONS — instance features
abap
GET PERMISSIONS ONLY INSTANCE FEATURES OF ZR_Reservation_###
ENTITY Reservation
FROM VALUE #(
( Uuid = uuid )
)
REQUEST VALUE #(
%action-confirm = if_abap_behv=>mk-on
%action-cancel = if_abap_behv=>mk-on
%field-Fee = if_abap_behv=>mk-on
%field-CurrencyCode = if_abap_behv=>mk-on
)
RESULT DATA(permissions)
FAILED DATA(failed_permissions)
REPORTED DATA(reported_permissions).Use it to ask:
text
Is this action enabled?
Is this field editable?for a specific instance.
29. Common feature constants
Actions / operations:
abap
if_abap_behv=>fc-o-enabled
if_abap_behv=>fc-o-disabledFields:
abap
if_abap_behv=>fc-f-unrestricted
if_abap_behv=>fc-f-read_onlyCommon EML Patterns
30. Create → mapped key → commit
text
MODIFY ENTITIES CREATE
↓
check FAILED
↓
read generated key from MAPPED
↓
COMMIT ENTITIES
↓
check save FAILED / REPORTED31. Create → read before commit
text
CREATE
↓
MAPPED gives UUID
↓
READ ENTITIES using UUID
↓
see transactional-buffer state
↓
COMMITUseful for proving:
text
managed numbering
determinations
transactional buffer32. Update → rollback test
text
READ original state
↓
MODIFY ENTITIES UPDATE
↓
READ changed buffer state
↓
ROLLBACK ENTITIES
↓
READ original persisted state33. Validation test
text
MODIFY invalid data
↓
interaction response
↓
COMMIT ENTITIES
↓
on-save validation
↓
FAILED + REPORTED
↓
ROLLBACK ENTITIES34. Action + feature test
text
GET PERMISSIONS
↓
EXECUTE action
↓
inspect RESULT
↓
COMMIT ENTITIES
↓
GET PERMISSIONS againCommon Mistakes
35. Direct SQL modification of RAP persistence
Avoid normal consumer code such as:
abap
UPDATE zresv_###It can bypass:
text
validations
determinations
actions
authorization
feature control
messages
transactional buffer
save sequenceUse EML.
36. Supplying a managed read-only UUID
If the BDEF has:
abap
field ( numbering : managed, readonly ) Uuid;use:
text
%cid → MAPPED → generated UuidDo not provide Uuid as normal create input.
37. Forgetting COMMIT
text
MODIFY ENTITIESdoes not mean:
text
transaction successfully persistedUse COMMIT ENTITIES when the consumer wants to complete the transaction.
38. Ignoring save responses
On-save validations can fail at:
text
COMMIT ENTITIESInspect save-phase:
text
FAILED
REPORTEDnot only the earlier modify response.
39. Using IN LOCAL MODE in external code
text
External consumer → normal EML
Provider → EML IN LOCAL MODE40. Committing inside a Behavior Pool handler
Do not use these inside normal RAP handler methods:
text
COMMIT ENTITIES
ROLLBACK ENTITIES
COMMIT WORK
ROLLBACK WORKThe consumer/runtime owns the transaction boundary.
41. Parsing message text to detect failure
Do not use message text as your failure API.
Use:
text
FAILEDfor programmatic failure state.
Use:
text
REPORTEDfor explanation.
42. Confusing %cid and %tky
text
%cid
→ create-request correlation ID
%tky
→ transactional BO instance identityCertification Quick Recall
43. Time-pressure memory map
text
READ
→ READ ENTITIES
CREATE / UPDATE / DELETE / ACTION
→ MODIFY ENTITIES
Create correlation
→ %cid
Generated key
→ MAPPED
Failure
→ FAILED
Message
→ REPORTED
Transactional identity
→ %tky
Action result
→ %param
Field message target
→ %element
Provider BO access
→ IN LOCAL MODE
Persist
→ COMMIT ENTITIES
Discard
→ ROLLBACK ENTITIES
Runtime feature query
→ GET PERMISSIONS44. One complete mini lifecycle
abap
" 1. CREATE
MODIFY ENTITIES OF ZR_Reservation_###
ENTITY Reservation
CREATE FIELDS (
ReservationNo
CustomerName
ReservationDate
Fee
CurrencyCode )
WITH VALUE #(
( %cid = 'RES_1'
ReservationNo = '98000001'
CustomerName = 'EML Student'
ReservationDate = cl_abap_context_info=>get_system_date( )
Fee = '100.00'
CurrencyCode = 'EUR' )
)
MAPPED DATA(mapped)
FAILED DATA(failed_create)
REPORTED DATA(reported_create).
IF failed_create IS NOT INITIAL.
ROLLBACK ENTITIES.
RETURN.
ENDIF.
DATA(uuid) =
mapped-reservation[ %cid = 'RES_1' ]-Uuid.
" 2. READ CURRENT TRANSACTION STATE
READ ENTITIES OF ZR_Reservation_###
ENTITY Reservation
ALL FIELDS
WITH VALUE #( ( Uuid = uuid ) )
RESULT DATA(before_commit)
FAILED DATA(failed_read).
" 3. SAVE
COMMIT ENTITIES
RESPONSE OF ZR_Reservation_###
FAILED DATA(failed_commit)
REPORTED DATA(reported_commit).Read it as:
text
create through BO
→ get generated identity
→ inspect transactional state
→ save through RAP45. Final rule
When working with a RAP-owned object, ask:
text
Am I working with the Business Object,
or bypassing it and working directly with its table?For normal transactional application code:
text
choose the Business Object
→ use EML