Skip to Content
Technical Articles

Entity Manipulation Language – EML | RAP Series

What is EML?

Entity Manipulation Language (EML) is a part of the ABAP language. It means that there are new syntaxes available in ABAP to

  • control the business object’s behavior in the context of ABAP RESTful programming model, using ABAP code user can manipulate Business Object created using ABAP RAP model
  • provides a type-save read and modifying access to data in transactional development scenarios.

Where%20EML%20comes%20into%20picture

Where EML comes into the picture

How EML syntaxes look like?

EML contains syntaxes to READ, MODIFY (Create, Update, Delete, Execute Actions) and COMMIT. Let’s understand each syntax step by step

READ ENTITIES

Read%20Entities%20Syntax

MODIFY ENTITIES – CREATE

MODIFY ENTITIES – UPDATE

MODIFY ENTITIES – DELETE

MODIFY ENTITIES – ACTION

 

Commit Entities syntax is clubbed with Modify syntaxes to logically complete the flow. LUW concept is there in all the MODIFY syntaxes.

MODIFY syntax manipulates Transactional Buffer and READ also get data from Transactional Buffer. In the case of Managed Behavior, managed runtime automatically populates data in Transactional buffer and in case of Unmanaged Behavior, a user needs to implement Transactional READ method of Behavior Implementation

Where is EML used?

Usually, Business objects that are implemented with the ABAP RESTful architecture based on the behavior definition and implementation of the interaction phase and save sequence in behavior pools can be consumed by means of OData protocol (Fiori UIs, or Web APIs)

Now to access them through ABAP code EML syntax is used.

The standard API is used whenever the “target” business object is statically specified. It provides code completion and static code checks. This typed API provides statements for read-only access to data (READ ENTITIES), as well as for modifying data access (MODIFY ENTITIES) and for triggering the save sequence (COMMIT ENTITIES), these all we saw above

The generic API is typically used for generic integration of business objects into other frameworks, such as the Cloud Data Migration Cockpit or the Process Test Framework.

What is the Use Case?

One of the uses cases of EML is the writing of test modules as ABAP Unit tests. As ABAP application developer, it gives you the ability to test the transactional behavior of business objects for each relevant operation that is defined in the behavior definition.

Another use-case is cross BO integration. Executing CRUDA operation of RAP based BO in another RAP based BO’ Implementation in exits like determination, validation, actions, etc.

 

From which release it is available?

EML – Entity Manipulation Language is available after 1902 Cloud release and 1909 on-premise release

 

Few points to note

  1. Multiple modify elements can be used in one MODIFY statement. The sequence of the operations is irrelevant.
  2. EML syntaxes for LUW concepts
  3. Authorizations will be automatically handled by these syntaxes, if a user needs to escape authorizations then just add syntax – IN LOCAL MODE
  4. READ by associations also works. From a parent entity, child entity can be read and vice versa.

 

Kindly share your thoughts on this blog and I will continue writing blogs on RAP topic.

 

Regards,

Yogesh Vijay

RAP Trainer, Development Learning

11 Comments
You must be Logged on to comment or reply to a post.
  • Hi
    My question is a little out of the question. It seems to me that expanding the syntax of a language for each function instead of building a library on top of an existing language is a strange solution?

    • Hi Sergey,

      In some sense you are right, however, when there is a new Programming Model came into the picture – which includes new artefacts like we have Behavior Definition, Behavior Implementation, etc then adding new syntaxes specific to that model is I guess fine.

      I can think of that there must be some limitation to build on top of existing language one. Anyways I will try to pass on this question to the relevant team and hope we get some answers to it.

       

      Thanks,

      Yogesh Vijay

    • I very much agree with this point. Why not take the modern approach used in, e.g., Java, Python and JS, where the core functionality is extended through libraries rather than adding new syntax to the language?

      • Hi Stoyko,

         

        What you are talking about is something totally different. Let say in python or java, if they introduce another library then you have new syntaxes right? For example, at one point of time if string library is added then string functions like concat, etc came into the picture. Similarly, with the new programming model, we have new artefact as Behavior definition and now to manipulate BO based on RAP there is new syntax. There is no existing library which was there which can be enhanced.

        What’s your thought?

         

        • Hey, Yogesh,

          I agree my choice of words could be clearer – I meant new core syntax. Other than this, I think my point is pretty clear – as you mention, Python or Java introduce new features using libraries. The core syntax of the language is the same, however. And very simple at that. There’s mainly just variables, arithmetic operations, conditionals, loops, classes, and functions/methods.

          Instead, what we see here in ABAP RAP is very different. Statements like READ ENTITIES OF, FAILED, REPORTED, etc. are now part of the core syntax. The language itself has been modified. If they were instead provided through a library as they would in Java or Python, it would be something like this:

          rap.read_entities_of(), rap.failed(), rap.reported()

          etc.

          See the difference?

          Another example would be how sin() in ABAP is a function part of the core syntax, but in Java it’s provided through the Math library. It’s not part of Java’s core syntax.

          Best,

          Stoyko

          • That’s a very good explanation, you are right what we have in JAVA or python.

            Here we can have libraries (usually we have using standard classes) but adding another artefact which simplifies user experience – If you see behavior definition, it is easy to understand what all operations are available for my Business Object.

            otherwise behind the scene things are same.

  • I tried to build a simple development, just to update a table depending on some vendor conditions, so I included the management in a BAdI.

    I had many problems at the moment of saving the data:

    • I cannot manage the rise of the COMMIT, so I can’t do COMMIT ENTITIES
    • Another problem, the vendor data is updated from CIG via API, this calls all saving process during the COMMIT, so I can’t perform the saving of data

    Workaround to save all data was implementing a new local class with data to save and a method to handle COMMIT, and from behaviour saver local class I call to this one.

    CLASS lcl_saver DEFINITION.
    
      PUBLIC SECTION.
        CLASS-METHODS get_instance
          RETURNING
            VALUE(ro_result) TYPE REF TO lcl_saver.
    
        METHODS add_data
          IMPORTING
            it_create TYPE arbcig_an_vendor_t OPTIONAL
            it_update TYPE arbcig_an_vendor_t OPTIONAL
            it_delete TYPE arbcig_an_vendor_t OPTIONAL.
    
        METHODS save.
    
        METHODS cleanup.
    
      PRIVATE SECTION.
        CLASS-DATA:
          go_saver TYPE REF TO lcl_saver.
    
        DATA:
          mt_create TYPE arbcig_an_vendor_t,
          mt_update TYPE arbcig_an_vendor_t,
          mt_delete TYPE arbcig_an_vendor_t.
    
        METHODS handler_transaction_finished
          FOR EVENT transaction_finished OF cl_system_transaction_state
          IMPORTING
            kind.
    
    ENDCLASS.
    CLASS lsc_Vendor DEFINITION INHERITING FROM cl_abap_behavior_saver.
      PROTECTED SECTION.
        METHODS save REDEFINITION.
        METHODS cleanup REDEFINITION.
    
    ENDCLASS.
    
    CLASS lsc_Vendor IMPLEMENTATION.
    
      METHOD save.
        lcl_saver=>get_instance( )->save( ).
      ENDMETHOD.
    
      METHOD cleanup.
        lcl_saver=>get_instance( )->cleanup( ).
      ENDMETHOD.
    
    ENDCLASS.

     

    This way, I can save the data at COMMIT and COMMIT ENTITIES.

     

    The solution to write the changes if EML is called during COMMIT, is to perform DB modifications directly in the CREATE/UPDATE/DELETE methods when sy-oncom = ‘P’

     

    I think that EML needs to take a look at this.

    • Hi Jaime,

       

      Doing this will break the LUW, we have actions also along with basic operations and an option of Unmanaged SAVE. This will create a problem in view 

      Here Commit work is implicitly handled by framework and ideally BAdI’s and BAPI or any FM should not contain COMMIT WORK inside.

       

      Any other thought?

      • Hi Yogesh,

        I think that I didn’t express myself correctly.

        I am not doing the COMMIT by my self, it is performed by a proxy class.

        This is the call stack:

        The “delete_company” method:

          METHOD delete_company.
        
            MODIFY ENTITIES OF zi_arbcig_an_vendor
              ENTITY Vendor
                DELETE FROM VALUE #( ( Company = iv_Company
                                       Vendor  = mv_vendor ) ).
        
          ENDMETHOD.

        I can’t execute the COMMIT ENTITIES in this situation

        /