ABAP Keyword Documentation → ABAP − Reference → ABAP RESTful Programming Model → Entity Manipulation Language
ABAP EML - READ ENTITIES
Other versions:
7.31 | 7.40 | 7.54
Syntax
READ ENTITIES OF root_name
ENTITY entity_1_name
FROM it_instance
RESULT it_result | DATA(it_result)
BY \assoc_name FROM it_instance_rba
RESULT it_result_rba | DATA(it_result_rba)
LINK it_link_rba | DATA(it_link_rba)
EXECUTE action_name FROM it_instance_a
RESULT it_result_a | DATA(it_result_a)
LINK it_link_a | DATA(it_link_a)
ENTITY entity_name_2
...
[FAILED it_failed | DATA(it_failed)]
[REPORTED it_reported | DATA(it_reported)].
Effect
The EML statement READ ENTITIES enables read operations to be made to the CDS entities. It can have a long, short, or dynamic form.
- The long form, READ ENTITIES, makes it possible to group multiple operations in multiple entities of a business object.
- The short form READ ENTITY is intended for the special case where only a single entity is operated on.
- The dynamic form READ ENTITIES OPERATIONS makes it possible to merge operations in multiple business objects in one statement. There is no dynamic short form.
The following points apply for the syntax of the statement READ ENTITIES:
- The name of the business object (the same as the name of the root entity) root_name is specified after OF.
- This is followed by the list of the operations, grouped by entity (schema):
ENTITY entity_name
operation
[operation ...]
Grouping operations by entity is not mandatory, since ENTITY entity_name can be repeated. The same combination of entity_name and operation, however, cannot occur more than once.
- The alias of the entity should be used as entity_name, if one is defined in the behavior definition. The original name of the entity can also be used instead of the alias, but this produces a warning.
- The simple READ ENTITIES statement does not have its own keyword (such as CREATE in MODIFY ENTITIES), rather it starts directly with FROM it_instance.
- READ ENTITIES statements always have the addition RESULT, since the result of the read must be specified.
- Two parameters are bound for each operation (source and target variable); in read-by-association, on the other hand, up to three variables (source and target variable and link) can be bound.
- Read-by-Association has the following form:
READ BY \association_name FROM instances
RESULT results
LINK links
Here, at least one of the target variables (results or links) must be specified. The variable results contains the target instances with all fields, whereas the variable links contains only a list of key pairs: Source key, target key. Target variables must have the appropriate type (for example, RESULT it_result_a) or can be declared inline (for example, RESULT DATA(it_result_a)).
The following applies for the response variables:
- The response variables are structures with n component (one component for each entity of the business object).
- Up to two variables can be specified to hold response information: FAILED and REPORTED. There are no key assignments in the statement READ ENTITIES, which is why the response structure MAPPED is not used.
- The response variables must either have the matching type or be declared inline (for example, FAILED DATA(it_failed)). These are the early response types (without the addition LATE). The instances are identified using the keys valid in the interaction phase.