Using the Entity Manipulation Language


After completing this lesson, you will be able to:

  • Implement an EML statement

Entity Manipulation Language Use

EML consists of statements that you can use to manipulate the data of a business object. You use the READ ENTITIES statement to read data; for all other operations, you use the MODIFY ENTITIES statement with the corresponding addition UPDATE, CREATE, or DELETE.


You can only use the CREATE, UPDATE, and DELETE operations if the behavior definition of the business object contains the corresponding use create, use update, or use delete directive. Trying to use a prohibited operation causes a syntax error.

To read data from a business object, you use the READ ENTITIES statement. The statement has two important parameters: one internal table containing the keys of the data that you want to read and another containing the results of the query.

These internal tables have special data types called derived behavior definition types. The system creates them automatically when a developer creates a behavior definition and they contain some or all of the fields of the business object along with further fields that control how the system processes a particular request. You declare the internal tables using the new addition TYPE TABLE FOR <operation> in the DATA statement.

The type TABLE FOR READ IMPORT contains the key field or fields of the business object. The %control structure is a generated structure that indicates which fields of the business object are actually used in the current operation. In our example, the system fills the structure automatically and you do not have to worry about it.

The type TABLE FOR READ RESULT contains all of the fields of the business object. This table contains the result set after the read statement has been executed.

The read import table contains a column for each key field of the business object, in this case, agencyID. To read a particular agency, you add a row to the internal table containing its key. As well as the key field or fields, the table contains the columns %is_draft and %control. With %is_draft you can specify whether you want to read draft data or active data. The %control structure is used to specify which fields are to be read.


In our example, we only read active data and the %control structure is filled by the framework, based on the field list after addition FIELDS.

When you process a business object, using the READ ENTITIES OF or MODIFY ENTITIES OF statement, you must first specify the name of the behavior definition. This is followed by keyword ENTITY and the name of the entity with which you want to work. If the entity has a alias name, you should use it, here.


You cannot use the alias name after addition OF. This is because the technically speaking, you specify the name of the behavior definition at this point, not the name of the entity.

The READ ENTITIES statement reads business object data according to the keys that you pass in the WITH addition. It returns the result in the internal table in the RESULT addition. In the statement, you can also specify which fields of the business object you need. In this example, we have used the ALL FIELDS addition to return all of the fields. However, if you only require a subset of the fields, you can use the variant FIELDS ( field1 field2 … ) to restrict the amount of data that is read. Note that, unlike in a SELECT statement, the field list is not comma-separated.

The result table contains all of the fields of the business object, along with the control field %is_draft. If your READ ENTITIES statement contains the FIELDS ( f1 … fn ) variant, only the fields that you requested will be filled. If you use the ALL FIELDS variant, the system provides the values of all of the fields.

If you want to update data, you declare an internal table with TYPE TABLE FOR UPDATE. This contains all of the fields of the business object and also the %control structure. In our variant of the MODIFY ENTITIES statement, the system fills the %control structure automatically.

The MODIFY ENTITIES statement updates data in the RAP transactional buffer. In the UPDATE FIELDS addition, you specify which fields should be changed. In the WITH addition, you pass the internal table containing the data that you want to update.

When you use EML outside the business object, you must use the COMMIT ENTITIES statement to trigger the RAP save sequence and persist the data in the database.


Later in this course we will use EML inside the behavior implementation. Inside the behavior implementation it is neither necessary nor allowed to trigger the commit with COMMIT ENTITIES.

How to Implement an EML Statement

Modify Data Using EML


  1. Open the data preview of table /DMO/AGENCY and note any value of AGENCY_ID. This is the record that you will change using EML.

    1. Press Ctrl + Shift + A to open the Open ABAP Development Object dialog box.

    2. Enter /DMO/AGENCY. There are several hits, to open the object with the Database Table type, double-clicking it.

    3. Press F8 to open the data preview.

    4. Note down any single value from the column AGENCY_ID.

  2. Create a new ABAP class called ZCL_##_EML, where ## is your group number. Ensure that the class implements the interface IF_OO_ADT_CLASSRUN.

    1. Choose FileNewABAP Class.

    2. Enter the name of your package in the Package field. In the Name field, enter the name ZCL_##_EML, where ## is your group number. Enter a description.

    3. In the Interfaces group box, choose Add.

    4. Enter IF_OO_ADT_CLASSRUN. When the interface appears in the hit list, double-click it to add it to the class definition.

    5. Choose Next.

    6. Select your transport request and choose Finish.

  3. In the method IF_OO_ADT_CLASSRUN~MAIN, declare an internal table with the correct derived type for updating the business object /DMO/R_AgencyTP. Fill it with a single line containing the AGENCY_ID that you noted in the first step and a new value for the field NAME.

    1. Navigate to the method IF_OO_DAT_CLASSRUN~MAIN and enter the following code (replace the values agencyID and Name with your own:

      Code snippet
      DATA update_tab TYPE TABLE FOR UPDATE /DMO/R_AgencyTP update_tab = VALUE #( ( agencyID = '070001' Name = 'MODIFIED Agency' ) ).Expand
  4. Modify the data, ensuring that only the field NAME is changed. Commit the changes.

    1. Enter the following code in the method implementation.

      Code snippet
      MODIFY ENTITIES OF /DMO/R_AgencyTP ENTITY /DMO/Agency UPDATE FIELDS ( name ) WITH update_tab. Expand
  5. Check whether your changes have been applied in table /DMO/AGENCY, yet.

    1. Proceed as described in step 1. You should find that your change has not been applied in the column NAME because you have not committed the changes, yet.

  6. Add statement COMMIT ENTITIES to your code to commit the changes.

    1. Navigate to the method IF_OO_DAT_CLASSRUN~MAIN.

    2. After the MODIFY ENTITIES statement, enter the following code:

      Code snippet
  7. Check that after the execution of the COMMIT ENTITIES statement your changes have been applied in table /DMO/AGENCY.

    1. Proceed as described in step 1. Ensure that your change has been applied in the column NAME.

Log in to track your progress & complete quizzes