EML Part 1: What EML Is — READ, MODIFY and COMMIT ENTITIES
Free sample lesson · open to everyone
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.
In this lessonShow sectionsHide sections
The situation: a 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.
Explanation
This series covers EML across five parts: this lesson covers what EML is — READ, MODIFY and COMMIT; Part 2 covers %cid, %cid_ref, MAPPED, FAILED and REPORTED; Part 3 covers IN LOCAL MODE and what it bypasses; Part 4 covers calling other BOs along with COMMIT ENTITIES and ROLLBACK ENTITIES; and Part 5 covers testing with EML and transactional consistency.
Entity Manipulation Language is part of ABAP and serves as the type-safe API to any RAP business object, whether your own or one of SAP's released ones. Instead of writing to tables directly, 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 actually uses the same mechanism internally, which is why an EML call and a Fiori action on the same BO behave identically.
EML shows up in several places: inside behavior implementations, to read and change your own BO (with IN LOCAL MODE, covered in Part 3); in ABAP programs, jobs and console classes, to create or change BO instances from code; when calling other BOs (Part 4); in ABAP Unit tests (Part 5); and in clean-core development, to change SAP data through SAP's released RAP BO interfaces rather than BAPIs or direct table updates.
The core statements are READ ENTITIES OF <bo> ENTITY <alias> FIELDS ( … ) | ALL FIELDS WITH <keys> RESULT <result>., which reads instances including buffer state, with BY \_Assoc used to read associated instances; MODIFY ENTITIES OF <bo> ENTITY <alias> CREATE | UPDATE | DELETE | EXECUTE <action> …, which changes instances or executes actions, with CREATE BY \_Assoc used to create children; COMMIT ENTITIES [RESPONSE OF <bo> FAILED … REPORTED …]., which triggers the save sequence and database commit and is only used outside behavior implementations; ROLLBACK ENTITIES., which discards the transactional buffer; and GET PERMISSIONS OF <bo> ENTITY <alias> …, which asks which operations are allowed — covering authorization and feature control — without actually executing them. Functions are executed via READ ENTITIES … EXECUTE <function>.
EML statements come in different forms. The short form targets one BO with one or more entities, as in "MODIFY ENTITIES OF zr_purchreq ENTITY PurchaseRequest UPDATE …". The long form covers several BOs in one statement, as in "MODIFY ENTITIES ENTITY zr_purchreq … ENTITY zr_other …", though this is rarely needed. The dynamic form, "MODIFY ENTITIES OPERATIONS op_table", is used when the BO or operation is only known at runtime, such as in generic tools.
Every operation takes a table as input. CREATE takes rows with %cid and field values, with FIELDS ( … ) stating which fields are supplied. UPDATE takes rows with the key (%tky) and values, where FIELDS ( … ) sets %control so that only those fields get changed. DELETE and EXECUTE take rows with keys, and %param for action parameters. Using FIELDS ( … ) WITH VALUE #( … ) is the safest form, because %control gets set automatically.
On the output side, the response parameters are MAPPED, which holds the keys assigned to new instances (%cid mapped to key); FAILED, which holds instances that couldn't be processed, along with %fail-cause; REPORTED, which holds messages; and RESULT, used for READ and for actions that return a result. FAILED and REPORTED should always be evaluated, a topic explored further in Part 2.
To try this out: create a class implementing if_oo_adt_classrun, paste in the code example and adapt the BO name, then run it with F9 to create, read, update, execute an action, commit, and print the results. After Part 1, the EML vocabulary is in place, and Part 2 goes deeper into correlation IDs and responses.
Animated technical walkthrough
Chapter-specific · EML · Part 1 · Read, modify and saveEML communicates with a business object, not its table
Stage 1 of 4
Call EML instead of writing to a table
An ABAP caller can READ ENTITIES or MODIFY ENTITIES using typed BO operations permitted by the behavior definition.
Illustrative BO layers; a native OData consumer receives transaction handling from the RAP runtime. This is a teaching model, not an actual SAP transaction trace.
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) " %cid -> real key assigned to the new instance (no key yet at this point) FAILED DATA(failed) " which operations failed, with a %fail-cause per instance REPORTED DATA(reported). " messages for the UI, not necessarily tied to a failure " 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.Watch out
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.
Do this
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.
In the interview
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
0 of 3 questions attempted
Question 1 of 3
A batch program inserts requests directly into the BO tables. Which consequence is most likely?
Question 2 of 3
When performing a partial update via EML MODIFY ENTITIES, what is the role of the %control structure component in the data table?
Question 3 of 3
Which EML statement is used to modify existing instances of a RAP business object using field-level update semantics?
Practise this in an interview
Answer in your own words and get instant feedback, the way an interviewer would judge it.
1What is EML, which statements does it have, and why should programs use EML instead of updating tables directly?
2A 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?
Try a related Code Lab
This published exercise covers the same SAP topic. Apply the ideas in a hands-on scenario, then return to review your answers.
Open: EML MODIFY Without Checking reported/failed →See it in code
Each example starts from a requirement, shows the design, then the code step by step with a plain-language explanation of every part.
Was this lesson helpful?
Keep exploring
Interview questions on this topic
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.