RAP Basics Part 10: EML — Entity Manipulation Language
Lessons are open to try during our launch period. Some advanced content may move to Pro later. AI practice limits apply separately.
Use EML to read and change RAP business objects from ABAP: READ ENTITIES, MODIFY ENTITIES (create, update, delete, create by association, execute action), the response parameters mapped/failed/reported, COMMIT ENTITIES and its rules, and when EML is used inside versus outside the BO.
In this lessonShow sectionsHide sections
Concept visual
EML operates on a business object's transactional state
READ ENTITIES / MODIFY ENTITIES
Call the RAP business-object interface from ABAP.
RAP transactional buffer
Proposed changes are held and checked before persistence.
MAPPED · FAILED · REPORTED
Inspect key mappings, rejected operations and diagnostic messages.
COMMIT ENTITIES / ROLLBACK ENTITIES
Complete or abandon the transaction from an external ABAP consumer.
Visual overview
The situation: a real project scenario
A migration team loaded 40,000 open travel requests into a new RAP BO with a report that looped over the legacy file and called MODIFY ENTITIES plus COMMIT ENTITIES per record, without checking the response. The run finished "successfully", but 3,100 records were missing — validations had rejected them and nobody read failed/reported.
The architect rewrote the program to process packages of 500 records per MODIFY/COMMIT, collect failed/reported into an error log with the legacy key (via %cid), and rerun only failed records. Runtime dropped from 6 hours to 50 minutes and every rejected record was explained.
Explanation
Part 9 used EML inside the behavior pool; here is the full language and how it's used from outside the business object. EML is the ABAP syntax for working with RAP business objects: READ ENTITIES, MODIFY ENTITIES, COMMIT ENTITIES, and ROLLBACK ENTITIES. Changes go to a transactional buffer first — nothing reaches the database until COMMIT ENTITIES is called, and that call is not allowed from inside the behavior pool's handler or saver methods, only from outside the BO.
READ ENTITIES looks like READ ENTITIES OF zi_travel ENTITY Travel FIELDS ( ... ) WITH ... RESULT lt_travel, and you can also read by association, for example ENTITY Travel BY \_Booking ALL FIELDS WITH ... RESULT lt_booking. Reads go through the buffer, so they see uncommitted changes from the same LUW.
MODIFY ENTITIES covers create, update, delete, and actions: CREATE FIELDS ( ... ) WITH VALUE #( ( %cid = 'T1' ... ) ) creates a new instance, and CREATE BY \_Booking ...
( %cid_ref = 'T1' %target = ... ) creates children for that new parent. %cid (content ID) is what links a new instance to its children within the same request, before real keys exist; UPDATE FIELDS ( ... ) WITH ..., DELETE FROM ..., and EXECUTE acceptTravel FROM ... cover the rest.
Every MODIFY ENTITIES call returns MAPPED, FAILED, and REPORTED structures — MAPPED gives you the final keys once they exist, and failed/reported should always be checked; ignoring them after MODIFY or COMMIT just hides errors.
COMMIT ENTITIES RESPONSE OF zi_travel FAILED ... REPORTED ... is what actually triggers the save sequence (finalize, check_before_save, save). After calling it, check sy-subrc and failed, and call ROLLBACK ENTITIES on error.
EML shows up in two broad contexts: inside the BO itself, in determinations and actions, where it's always used IN LOCAL MODE, and outside the BO, in background jobs, migration programs, other business objects, and unit tests. It's also how custom code consumes SAP's own released business objects — for example I_SalesOrderTP — making it the clean-core alternative to calling BAPIs directly.
Two special modes are worth knowing: IN LOCAL MODE is only usable inside the implementing BO and skips feature and authorization checks, while PRIVILEGED mode skips authorization checks for business objects that explicitly support it, via a privileged mode declared in the BDEF.
To put this into practice: write a report that creates a travel with two bookings using %cid, check failed and reported after the MODIFY, call COMMIT ENTITIES and check the response, and then read the created travel back with READ ENTITIES to display it. By the end, the report should create a travel with bookings, print the new TravelID, and show messages if a validation fails.
Code example
REPORT ztravel_eml_demo. * ===== STEP 1: create a travel and two bookings in one MODIFY (%cid) =====DATA ls_mapped TYPE RESPONSE FOR MAPPED EARLY zi_travel.DATA ls_failed TYPE RESPONSE FOR FAILED EARLY zi_travel.DATA ls_reported TYPE RESPONSE FOR REPORTED EARLY zi_travel.DATA ls_fail_l TYPE RESPONSE FOR FAILED LATE zi_travel.DATA ls_rep_l TYPE RESPONSE FOR REPORTED LATE zi_travel.DATA ls_map_tr LIKE LINE OF ls_mapped-travel.DATA lt_travel TYPE TABLE FOR READ RESULT zi_travel\travel.DATA ls_travel LIKE LINE OF lt_travel.DATA lv_lines TYPE i. MODIFY ENTITIES OF zi_travel ENTITY Travel CREATE FIELDS ( AgencyID CustomerID BeginDate EndDate CurrencyCode ) WITH VALUE #( ( %cid = 'T1' AgencyID = '070001' CustomerID = '000010' BeginDate = sy-datum EndDate = sy-datum + 7 CurrencyCode = 'EUR' ) ) CREATE BY \_Booking FIELDS ( FlightDate ) WITH VALUE #( ( %cid_ref = 'T1' %target = VALUE #( ( %cid = 'B1' FlightDate = sy-datum ) ( %cid = 'B2' FlightDate = sy-datum + 7 ) ) ) ) MAPPED ls_mapped FAILED ls_failed REPORTED ls_reported. * ===== STEP 2: check the interaction-phase response =====DESCRIBE TABLE ls_failed-travel LINES lv_lines.IF lv_lines > 0. WRITE: / 'Create failed in interaction phase'. ROLLBACK ENTITIES. RETURN.ENDIF. * ===== STEP 3: commit - runs validations and save sequence =====COMMIT ENTITIES RESPONSE OF zi_travel FAILED ls_fail_l REPORTED ls_rep_l. IF sy-subrc <> 0. WRITE: / 'Save rejected - check validations'. ROLLBACK ENTITIES. RETURN.ENDIF. * ===== STEP 4: read back the committed travel =====READ TABLE ls_mapped-travel INTO ls_map_tr INDEX 1.READ ENTITIES OF zi_travel ENTITY Travel ALL FIELDS WITH VALUE #( ( TravelUUID = ls_map_tr-TravelUUID ) ) RESULT lt_travel. READ TABLE lt_travel INTO ls_travel INDEX 1.IF sy-subrc = 0. WRITE: / 'Travel created:', ls_travel-TravelID, ls_travel-OverallStatus.ENDIF.Watch out
Common mistakes
- Not checking failed/reported after MODIFY ENTITIES and COMMIT ENTITIES.
- Calling COMMIT ENTITIES inside a determination, action or saver method.
- Committing per record in mass programs instead of in packages.
- Forgetting %cid/%cid_ref when creating parent and children in one request.
- Using IN LOCAL MODE outside the implementing BO (not allowed).
Do this
Best practices
- Always evaluate mapped, failed and reported; log messages with the business key.
- Commit in packages for mass processing.
- Use %cid values derived from the source key to trace errors.
- Prefer EML on released SAP BOs over BAPIs in S/4HANA clean-core development.
- Use EML in ABAP Unit tests to test BO behavior end to end.
In the interview
Interview angle
Questions: "What is EML?", "What is %cid used for?", "Can you use COMMIT ENTITIES in a determination?"
Strong answer: EML is the ABAP language for RAP BOs — READ/MODIFY/COMMIT/ROLLBACK ENTITIES — working on the transactional buffer. %cid identifies new instances before keys exist so children can be created in the same request; mapped returns the final keys. COMMIT ENTITIES triggers the save sequence and is only allowed outside the BO's handler and saver methods; results must be checked via failed/reported and sy-subrc.
Practice this lesson
Quick check
0 of 3 questions attempted
Question 1 of 3
In MODIFY ENTITIES, what is %cid used for?
Question 2 of 3
A report calls MODIFY ENTITIES OF zi_travel to create travels, checks failed (empty), but no data reaches the database. What is missing?
Question 3 of 3
Where is COMMIT ENTITIES not allowed?
Practise this in an interview
Answer in your own words and get instant feedback, the way an interviewer would judge it.
1A batch program called MODIFY ENTITIES to create orders and immediately reported success, but nothing appeared in the database and some records were never explained. What is wrong?
2Why should direct database updates be avoided for RAP business objects?
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: Direct Table Update Bypassing RAP Behavior →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.