This page teaches EML, the ABAP statements that read and change RAP business objects: READ, MODIFY, COMMIT and ROLLBACK ENTITIES, derived types, responses, permissions, locks, local mode and privileged access. It implements R12 – other ABAP programs and a nightly job create and approve sales orders through the same checks as the Fiori app.
Part 1 – Why EML: one front door for every caller
Requirements on this page
R-ID | Requirement | Where on this page |
|---|---|---|
R12 | Other ABAP programs and a nightly job create or approve orders | Parts 1–6, full job in Part 6 |
R7 / R3 | Approve only for status N and only for managers – also when a program calls it | Part 5 (permissions, local mode, privileged) |
R18 | Create SAP's standard sales order from our order | One line here; EML on |
R20 | Automated tests | Tests also use EML → 12 · Extensibility & Testing |
R12 – besides the Fiori app, other ABAP programs and a nightly job must create orders and approve them. They must go through exactly the same checks as a rep or a manager in the app: status N on create (R4), customer validation (R6), "Approve only for status N and only for managers" (R7), locks (R10), the order number (R9) and the audit log (R14).
EML (Entity Manipulation Language) is the set of ABAP statements that read and change RAP business objects – your own BO or SAP's released BOs such as I_SalesOrderTP. Think of it as the front desk of a hotel: every request goes through the desk, so the BO's checks always run. A program that writes zsales_hdr with UPDATE sneaks into the kitchen and skips all of them.

Where EML is used: in behavior pools (to read or change your own BO), in other classes, reports and background jobs (R12), in ABAP Unit tests (R20) and to call SAP's released BOs instead of BAPIs (R18).

The statements at a glance
Statement | What it does | Where allowed |
|---|---|---|
READ ENTITIES OF zr_salesorder | Reads instances from the transactional buffer (or the database if not yet buffered), also by association ( | Everywhere |
MODIFY ENTITIES OF zr_salesorder | CREATE, CREATE BY association, UPDATE, DELETE, EXECUTE action – changes go only to the buffer | Handlers and consumer code |
COMMIT ENTITIES | Starts the save sequence: finalize → check_before_save → adjust_numbers → save → cleanup | Only in consumer code (class, report, job, test) – never in a behavior pool |
ROLLBACK ENTITIES | Throws away the whole buffer and releases the locks | Consumer code |
GET PERMISSIONS | Asks which operations, actions and fields are allowed (feature control + authorization) without executing anything | Everywhere |
SET LOCKS | Locks instances explicitly (MODIFY normally locks automatically) | Handlers and consumer code |
| Short form for one entity | Same as the long form |
| Dynamic form – BO and entity names at runtime (generic tools) | Same as the long form |
MODIFY AUGMENTING ENTITY | Enriches a request in a projection behavior pool → 04 · Behavior Definition & Behavior Pool | Projection behavior pool only |
- A program in another software component should call the BO through its interface BDEF (released, stable), not the
ZR_base BO → 04 · Behavior Definition & Behavior Pool.
Part 2 – READ ENTITIES and MODIFY ENTITIES
READ ENTITIES
|
order_uuidstands for a key you selected before.FIELDS ( ... )fills%controlfor you;ALL FIELDSrequests every field.- READ sees what is in the buffer, including unsaved changes of the same transaction. A plain SELECT does not – one reason to use READ ENTITIES inside handlers.
- Instances that do not exist come back in
FAILEDwith%fail-cause = if_abap_behv=>cause-not_found, not as an exception.
MODIFY ENTITIES – a program creates an order (R12)
|
- Status, OrderUUID and the item key are not sent: the determination
setInitialStatussets status N (R4), managed numbering creates the UUIDs, andcalculateTotalfills the net amount (R5).
|
The same UPDATE written with a typed table and an explicit %control – this is what FIELDS ( ... ) does behind the scenes (order is a row of a READ result):
|
The factory action copyOrder (R8) creates a new instance, so it needs a %cid; the new key comes back in MAPPED:
|
- Without
%control(orFIELDS), an UPDATE changes nothing – RAP only touches fields whose control flag ismk-on. This is how RAP tells "set to initial" apart from "not sent". - Status is
readonlyfor consumers. A program that wants status A must callapprove, not UPDATE Status – the action carries the R7 rules. CREATE AUTO FILL CIDlets RAP generate the%cidvalues when you do not need to reference them (check your release).
Part 3 – Derived types and component groups
Every BDEF automatically gives you derived types – structures and tables whose shape follows the BO. They contain the entity fields plus special component groups that start with %.

Component | Meaning | Typical use |
|---|---|---|
| Content ID: temporary name for a new instance / reference to it | Create header + items in one MODIFY; factory action |
%key | Primary key fields only (OrderUUID) | Non-draft keys, database lookups |
%pid | Preliminary ID before late numbering assigns the real key | Late numbering → 06 · Feature Control, Authorization & Numbering |
%pky |
| Keys that must work with late numbering |
%is_draft | '01' draft instance, '00' active ( | Draft BOs → 07 · Locking, Draft & Side Effects |
%tky | Transactional key = | Use it everywhere in handlers |
%control | One flag per field: was it sent / is it requested ( | UPDATE, CREATE, READ |
%data | All entity fields as one substructure | Copy all field values at once |
%param | Action/function parameter (import) or result row |
|
%target | Child rows in CREATE BY association | Header + items in one call |
%fail | In FAILED: | Why an instance failed |
| Message object / field to highlight / message group / messages without instance | REPORTED → 05 · Business Logic & Messages |
| Flags in permission, feature and authorization requests and results | GET PERMISSIONS, feature control |
|
\+ association name = by-association type,\\+ alias = a specific entity,~+ name = action, function or event.EARLY/LATEin RESPONSE types: early = interaction phase and early save, late = late save (adjust_numbers,save,save_modified). Without the addition, EARLY is meant.
Part 4 – Responses and COMMIT ENTITIES
EML never raises an exception for a business error. Each statement returns three response structures, with one internal table per entity (failed-salesorder, failed-item, ...). In a nightly job nobody watches the screen – if you do not check them, a rejected order goes unnoticed.

|
After | Check | Meaning |
|---|---|---|
MODIFY / READ | failed-<entity> | Instance rejected (not found, locked, unauthorized, disabled ...) |
MODIFY / READ |
| Messages for the user or the log |
MODIFY CREATE | mapped-<entity> | %cid → real key (or %pid with late numbering) |
COMMIT ENTITIES |
| Saved |
COMMIT ENTITIES |
| Early save failed (finalize / check_before_save, e.g. |
COMMIT ENTITIES |
| Late save failed (after the point of no return, e.g. a saver raised |
COMMIT ENTITIES variants
|
- Simulation mode is useful for a "check" step in a custom tool or a test: you learn whether the validations pass without saving.
CONVERT KEYis needed only for BOs whose key uses late numbering, such as SAP'sI_SalesOrderTP(R18): MAPPED has only the%pid, and the real number exists only inside the commit scope. Our order key is a UUID, so MAPPED already has the finalOrderUUID.
Part 5 – GET PERMISSIONS, SET LOCKS, IN LOCAL MODE and PRIVILEGED
GET PERMISSIONS and SET LOCKS
|
- Other variants:
ONLY INSTANCE,ONLY FEATURES,ONLY AUTHORIZATIONand combinations such asONLY GLOBAL FEATURES(check the keyword documentation of your release). - GET PERMISSIONS only asks; the real check runs again when you execute. A custom tool uses it to grey out buttons, not as a security check.
IN LOCAL MODE and PRIVILEGED
Addition | Skips | Who may use it |
|---|---|---|
(none) | Nothing – all checks run, like for a Fiori user | Any consumer, e.g. the nightly job (R12) |
IN LOCAL MODE | Feature control and authorization checks of the BO itself | Only the BO's own implementation (e.g. |
PRIVILEGED | Only the authorization checks that the BDEF lists in the authorization context for privileged mode | Any trusted consumer, only if the BDEF declares |
|
PRIVILEGEDskips authorization only – feature control still applies, so approve on an order that is not in status N fails even in privileged mode (R7).FORWARDING PRIVILEGED(BTP 2408) passes the caller's privileged mode on to a BO you call from your handler – check your release.
Part 6 – R12 end to end: the nightly approval job
The business wants small orders approved automatically every night, so managers only see the large ones. In ABAP Cloud the job is an application job: a class that implements the released interfaces IF_APJ_DT_EXEC_OBJECT (design time: parameters) and IF_APJ_RT_EXEC_OBJECT (runtime: execute) – the older pattern, still released; current releases: IF_APJ_RT_RUN (execute). On-premise the same EML code can also run in a report scheduled in SM36.
|
- The limit 500 is a placeholder for the business rule; a real job reads it from a job parameter.
- The job runs under its own user. That user needs the approval authorization (R7) – or the BO offers privileged mode for this caller (Part 5). Do not "fix" a missing role with
IN LOCAL MODE; it is not allowed outside the BO. - An order a rep is editing in draft right now is locked (exclusive lock phase of the draft): approve returns it in
failed-salesorderwith%fail-cause = locked. The job tries again the next night; details on draft locks → 07 · Locking, Draft & Side Effects. - An application job also needs a job catalog entry and a job template so it can be scheduled in the *Application Jobs* app (check your release for the ADT wizard).
- Large volumes: commit in packages (e.g. 500 orders per MODIFY + COMMIT ENTITIES) so one failing early save does not hold back all orders and the buffer stays small.
Newer EML additions (check your release)
Feature | What it does | Since |
|---|---|---|
READ ENTITIES ... IN LOCAL MODE ... WITH CHANGES | Read that also returns what changed in the current transaction (managed BOs only) | BTP 2511 |
SET ENTITIES | Blocks or unblocks EML access to BOs in a program section | ABAP 7.58 (S/4HANA 2023) |
No EML reads in the late save |
| BTP 2408 |
CL_ABAP_BEHV_AUX |
| Released auxiliary class |
Contract checks | Runtime error | Newer BTP releases |
Common mistakes
COMMIT ENTITIESorCOMMIT WORKinside a behavior pool → runtime error. The OData request or your consumer commits.- Using
%keyinstead of%tkyin a draft BO → you read or change the active instance instead of the draft (or get not_found). - Forgetting
%control/FIELDS→ UPDATE "succeeds" but changes nothing. - Not checking
sy-subrcafterCOMMIT ENTITIES→ a failed validation goes unnoticed in the nightly job. - Using
IN LOCAL MODEfrom a consumer class – it is only allowed in the BO's own implementation. UPDATE zsales_hdrfrom a program "because it is faster" → no R4–R9 checks, no lock, no audit log (R14), and the ETag of open drafts is not respected.
Interview tip
- "What happens between MODIFY and COMMIT ENTITIES?" → MODIFY runs the interaction phase (locks, feature control, authorization, determinations on modify) and only fills the buffer. COMMIT ENTITIES runs the save sequence; sy-subrc 4 = early save (validation) failed, 8 = late save failed.
Part 7 – Interview questions
Q1. What is EML, and what are its main statements?
Entity Manipulation Language – ABAP statements to read and change RAP BOs: READ ENTITIES, MODIFY ENTITIES (create, create by association, update, delete, execute action), COMMIT ENTITIES and ROLLBACK ENTITIES, plus GET PERMISSIONS and SET LOCKS. It works for your own BOs and SAP's released ones such as I_SalesOrderTP, and every call passes the BO's checks.
Q2. Why IN LOCAL MODE, and what are %cid, %tky, %key and %control?
IN LOCAL MODE skips feature control and authorization inside the BO's own implementation – the determination setInitialStatus may set the read-only Status. %cid is a temporary ID for a new instance within one request (children refer to it with %cid_ref); %key holds the primary key; %tky = %key + %is_draft (+ %pid with late numbering) and should be used in handlers; %control flags which fields are supplied or requested.
Q3. Where may COMMIT ENTITIES be used, and what does sy-subrc tell you afterwards?
Only in consumer code – a class, report, application job or unit test – never in a behavior pool, where the OData request or the caller commits. sy-subrc 0 = saved; 4 = the early save failed (a validation or check_before_save rejected the data, nothing saved, buffer kept – fix or ROLLBACK ENTITIES); 8 = the late save failed and the transaction was rolled back.
Q4. An EML UPDATE returns no errors but nothing changes. Why?
The %control flags were not set – neither FIELDS ( ... ) nor %control-<field> = mk-on. RAP only changes fields whose control flag is on, so it can tell "set to initial" from "not sent". Another classic: the program never called COMMIT ENTITIES, so the change stayed in the buffer.
Q5. A nightly job must approve orders. How do you build it, and what can go wrong?
An application job class (IF_APJ_RT_RUN; older pattern IF_APJ_DT_EXEC_OBJECT / IF_APJ_RT_EXEC_OBJECT) that selects candidates from the CDS view, calls EXECUTE approve through EML, then COMMIT ENTITIES with a sy-subrc check, and logs FAILED/REPORTED in the application log. Pitfalls: the job user lacks the approval authorization, orders in draft are locked by a user, orders not in status N are rejected by feature control, and unchecked responses hide all of it.
Q6. Why not update zsales_hdr directly from the program – it is faster?
A direct UPDATE skips everything the BO guarantees: determinations (status, total), validations, feature control, authorization, locks and ETags, numbering and the additional save that writes the audit log. Draft users would also overwrite each other. EML is the only supported way to change a RAP BO.
Q7. IN LOCAL MODE vs PRIVILEGED?
IN LOCAL MODE is only allowed inside the BO's own implementation and skips its feature control and authorization. PRIVILEGED is for trusted external consumers and skips only the authorization checks the BDEF lists in its privileged authorization context; feature control still runs. Without with privileged mode in the BDEF, PRIVILEGED is not possible.
Q8. What is CONVERT KEY for?
For BOs whose key is assigned by late numbering, such as I_SalesOrderTP. After MODIFY, MAPPED holds only the preliminary %pid. Between COMMIT ENTITIES BEGIN and COMMIT ENTITIES END, CONVERT KEY turns the %pid into the final key, e.g. the real sales order number.
Q9. What does READ ENTITIES return that a SELECT does not?
READ ENTITIES reads the transactional buffer, so it sees unsaved changes of the current transaction and draft instances via %tky, and it reports missing instances in FAILED. A SELECT reads only what is already committed in the database – inside handlers that is usually stale.
🏠 Start Here · ◀ 07 · Locking, Draft & Side Effects · 09 · Unmanaged & Save Variants ▶ · 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 | GTM ABAP | EHS ABAP | HR ABAP | BW | SAP Datasphere | SAP Business Data Cloud | SAP MDG | SAP Analytics Cloud | SAP Ariba | SAP CX | SAP IBP