EML Part 1: What EML Is — READ, MODIFY and COMMIT ENTITIES
Learn Entity Manipulation Language (EML) — the ABAP statements to read, change and commit RAP business objects — with the short and long forms, response parameters, and where EML is used.
What this complete series covers
Learn EML in a clear, practical sequence — from the basic idea to real project use, troubleshooting, and interview-ready understanding.
- Who it is for
- Best for SAP consultants, developers, and learners who want a practical understanding of EML.
- Prerequisites
- Basic ABAP and ADT in Eclipse are recommended. The series explains the RAP/CDS/OData concepts as they are introduced.
- Final outcome
- By the end, you should be able to explain EML clearly, follow the main end-to-end flow, apply it in a project scenario, and troubleshoot the most common issues.
- Part 1: EML Part 1: What EML Is — READ, MODIFY and COMMIT ENTITIES
Use Entity Manipulation Language as the type-safe ABAP API to RAP business objects, preserving behavior, authorization, feature, validation, and transaction semantics instead of re
- Part 2: EML Part 2: %cid, %cid_ref, MAPPED, FAILED and REPORTED
Master EML request correlation and response handling so new temporary instances can reference each other and clients can distinguish generated keys, failed instances, and business messages reliably.
- Part 3: EML Part 3: IN LOCAL MODE — What It Bypasses and When It Is Safe
Use EML IN LOCAL MODE only inside the owning behavior pool for trusted internal BO logic, understanding that it can bypass authorization, feature control, access control, and prech
- Part 4: EML Part 4: Cross-BO Calls, COMMIT ENTITIES and ROLLBACK ENTITIES
Consume released RAP business objects from ABAP while respecting authorization and transaction semantics, and use COMMIT ENTITIES or rollback only at the correct top-level boundary.
- Part 5: EML Part 5: Testing RAP with EML and Transactional Consistency
Build behavior-level automated tests with EML, including create/update/action scenarios, commit validation, rollback isolation, and save-sequence simulation where supported.
System and release assumptions: Examples target recent SAP S/4HANA / ABAP Cloud capabilities. RAP, CDS, OData, and Fiori Elements syntax and tooling can differ by ABAP platform release.
Explanation
📌 KEY POINTS
✅ READ ENTITIES, MODIFY ENTITIES, COMMIT ENTITIES, ROLLBACK ENTITIES, GET PERMISSIONS.
✅ EML runs the full BO behavior — unlike direct table updates.
✅ UPDATE FIELDS ( … ) sets %control for partial updates.
⚠️ Validations run at COMMIT ENTITIES, not at MODIFY.
▶ WHAT THIS SERIES COVERS
- Part 1 — what EML is: READ, MODIFY, COMMIT (this lesson)
- Part 2 — %cid, %cid_ref, MAPPED, FAILED and REPORTED
- Part 3 — IN LOCAL MODE: what it bypasses and when it is safe
- Part 4 — calling other BOs, COMMIT ENTITIES and ROLLBACK ENTITIES
- Part 5 — testing with EML and transactional consistency
━━━━━━━━━━━━━━━━━━━━
▶ WHAT EML IS
Entity Manipulation Language is part of ABAP. It is the type-safe API to any RAP business object — your own or SAP's released ones. Instead of writing to tables, you ask the business object to do something, and it runs its full behavior: authorization, feature control, determinations, validations, locking, numbering, draft.
The OData layer uses the same mechanism internally, so an EML call and a Fiori action on the same BO behave identically.
━━━━━━━━━━━━━━━━━━━━
▶ WHERE EML IS USED
- Inside behavior implementations — to read and change your own BO (with IN LOCAL MODE, Part 3).
- In ABAP programs, jobs, console classes — to create or change BO instances from code.
- In other BOs — to call another business object (Part 4).
- In ABAP Unit tests (Part 5).
- In clean-core development — to change SAP data through SAP's released RAP BO interfaces instead of BAPIs or table updates.
━━━━━━━━━━━━━━━━━━━━
▶ THE STATEMENTS
- READ ENTITIES OF <bo> ENTITY <alias> FIELDS ( … ) | ALL FIELDS WITH <keys> RESULT <result>. — read instances (buffer state included). BY \_Assoc reads associated instances.
- MODIFY ENTITIES OF <bo> ENTITY <alias> CREATE | UPDATE | DELETE | EXECUTE <action> … — change instances or execute actions. CREATE BY \_Assoc creates children.
- COMMIT ENTITIES [RESPONSE OF <bo> FAILED … REPORTED …]. — triggers the save sequence and database commit. Only outside behavior implementations.
- ROLLBACK ENTITIES. — discards the transactional buffer.
- GET PERMISSIONS OF <bo> ENTITY <alias> … — asks which operations are allowed (authorization and feature control) without executing them.
- Functions are executed via READ ENTITIES … EXECUTE <function>.
━━━━━━━━━━━━━━━━━━━━
▶ SHORT FORM AND LONG FORM
- Short form: one BO, one or more entities — "MODIFY ENTITIES OF zr_purchreq ENTITY PurchaseRequest UPDATE …".
- Long form: several BOs in one statement — "MODIFY ENTITIES ENTITY zr_purchreq … ENTITY zr_other …" — rarely needed.
- Dynamic form: "MODIFY ENTITIES OPERATIONS op_table" — when the BO or operation is known only at runtime (generic tools).
━━━━━━━━━━━━━━━━━━━━
▶ INPUT: TABLES OF INSTANCES
Every operation takes a table:
- CREATE: rows with %cid and field values; FIELDS ( … ) says which fields you supply.
- UPDATE: rows with the key (%tky) and values; FIELDS ( … ) sets %control, so only these fields are changed.
- DELETE / EXECUTE: rows with keys (and %param for action parameters).
Using FIELDS ( … ) WITH VALUE #( … ) is the safest form because %control is set automatically.
━━━━━━━━━━━━━━━━━━━━
▶ OUTPUT: RESPONSE PARAMETERS
- MAPPED — keys assigned to new instances (%cid → key).
- FAILED — instances that could not be processed, with %fail-cause.
- REPORTED — messages.
- RESULT — for READ and for actions with result.
Always evaluate FAILED and REPORTED (Part 2).
━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP
- Create a class implementing if_oo_adt_classrun.
- Paste the code example; adapt the BO name.
- Run with F9: create, read, update, execute an action, commit, and print the results.
━━━━━━━━━━━━━━━━━━━━
▶ WHAT YOU HAVE AFTER PART 1
The EML vocabulary. Part 2 goes deep into correlation IDs and responses.
Code example
" ===== Console class: the core EML statements =====CLASS zcl_eml_demo DEFINITION PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES if_oo_adt_classrun.ENDCLASS. CLASS zcl_eml_demo IMPLEMENTATION. METHOD if_oo_adt_classrun~main. " 1. CREATE (interaction phase - goes to the transactional buffer) MODIFY ENTITIES OF zr_purchreq ENTITY PurchaseRequest CREATE FIELDS ( Description CurrencyCode ) WITH VALUE #( ( %cid = 'R1' Description = 'Office chairs' CurrencyCode = 'EUR' ) ) MAPPED DATA(mapped) FAILED DATA(failed) REPORTED DATA(reported). " 2. READ (sees buffered, uncommitted data) READ ENTITIES OF zr_purchreq ENTITY PurchaseRequest ALL FIELDS WITH VALUE #( ( %tky = mapped-purchaserequest[ 1 ]-%tky ) ) RESULT DATA(requests). " 3. UPDATE only one field (FIELDS sets %control) MODIFY ENTITIES OF zr_purchreq ENTITY PurchaseRequest UPDATE FIELDS ( Description ) WITH VALUE #( ( %tky = requests[ 1 ]-%tky Description = 'Ergonomic office chairs' ) ). " 4. EXECUTE an action (behavior, feature control, authorization all apply) MODIFY ENTITIES OF zr_purchreq ENTITY PurchaseRequest EXECUTE submit FROM VALUE #( ( %tky = requests[ 1 ]-%tky ) ) RESULT DATA(submit_result) FAILED DATA(submit_failed) REPORTED DATA(submit_reported). " 5. Ask what is allowed, without doing it GET PERMISSIONS ONLY INSTANCE FEATURES ENTITY zr_purchreq " root entity by BDEF name FROM VALUE #( ( %tky = requests[ 1 ]-%tky ) ) REQUEST VALUE #( %update = if_abap_behv=>mk-on %action-approve = if_abap_behv=>mk-on ) RESULT DATA(permissions) FAILED DATA(perm_failed) REPORTED DATA(perm_reported). " 6. COMMIT: save sequence (determinations on save, validations, save) COMMIT ENTITIES RESPONSE OF zr_purchreq FAILED DATA(commit_failed) REPORTED DATA(commit_reported). IF commit_failed IS INITIAL. out->write( |Saved. Submit failed entries: { lines( submit_failed-purchaserequest ) }| ). ELSE. out->write( 'Save rejected - see messages' ). ROLLBACK ENTITIES. " discard the buffer ENDIF. ENDMETHOD.ENDCLASS.Real project scenario
A batch program for mass-creating purchase requests from a spreadsheet inserted rows directly into the BO's tables with INSERT. The requests appeared in the Fiori app, but without status, without request numbers, without change log entries, and some violated validations that the app enforced.
The program was rewritten with EML: MODIFY ENTITIES CREATE for each chunk of 500 rows, COMMIT ENTITIES RESPONSE, and a log of FAILED/REPORTED per row. All determinations and validations now ran exactly as in the UI; invalid rows were reported back instead of silently created.
Common mistakes
- Writing to BO tables directly instead of using EML.
- Ignoring FAILED and REPORTED.
- Using COMMIT ENTITIES inside a behavior implementation.
- Updating with a full structure without FIELDS ( … ), overwriting fields unintentionally.
- Expecting validations to run on MODIFY — they run at COMMIT ENTITIES.
- Using the plain key instead of %tky for draft-enabled BOs.
Best practices
- Use EML for every change to a RAP BO, including mass programs.
- Always use FIELDS ( … ) WITH VALUE #( … ) so %control is correct.
- Evaluate FAILED/REPORTED after MODIFY and after COMMIT ENTITIES.
- Commit in chunks in mass programs; log per instance.
- Use GET PERMISSIONS to check what is allowed before offering an operation.
Interview angle
Questions: "What is EML?", "Which EML statements exist?", "Why use EML instead of updating tables?"
Strong answer: EML is the ABAP language part for RAP BOs: READ ENTITIES, MODIFY ENTITIES (create, update, delete, execute, create-by-association), COMMIT ENTITIES, ROLLBACK ENTITIES and GET PERMISSIONS. It runs the full BO behavior, so authorization, determinations, validations and locking apply — unlike direct table updates. Mention FIELDS for %control, the response parameters and that validations run at commit.
Practice this lesson
Quick check
1. A batch program inserts requests directly into the BO tables. Which consequence is most likely?
2. When performing a partial update via EML MODIFY ENTITIES, what is the role of the %control structure component in the data table?
3. Which EML statement is used to modify existing instances of a RAP business object using field-level update semantics?
Interview questions
1. What is EML, which statements does it have, and why should programs use EML instead of updating tables directly?
Answer it in your own words first, then compare.
2. A mass-upload program inserts purchase requests directly into the BO tables. Requests appear in the app without status or number and some violate rules. How do you rewrite it?
Answer it in your own words first, then compare.
Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.