SAP EML READ ALTERNATIVES ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_EML - READ, Variants
This example demonstrates the variants of the ABAP_EML READ statement to read data from a simple managed RAP BO:
READ ENTITY bdef
READ ENTITIES OF bdef
READ ENTITIES OPERATIONS dynop
Data model
The CDS data model consists of the root entity DEMO_SPFLI_FLIGHTS and its child entity DEMO_SFLIGHT. The root entity represents flight schedule data and the child entity represents flight details.
Root entity:
DDLS DEMO_SPFLI_FLIGHTS
Child entity:
DDLS DEMO_SFLIGHT
Behavior definition
The RAP behavior definition DEMO_SPFLI_FLIGHTS is defined in RAP BDL as follows:
BDEF DEMO_SPFLI_FLIGHTS
Behavior implementation
For the above RAP behavior definition, one ABAP behavior pool (ABP) is created. The global class of the behavior pool is BP_DEMO_SPFLI_FLIGHTS. This global class implements the local handler class LHC_DEMO_SPFLI_FLIGHTS. The actual implementation takes place in the BP_DEMO_SPFLI_FLIGHTS=========CCIMP. The details of the behavior implementation are not relevant for this example since no custom operations are used here.

ABAP_SOURCE_CODE
DEMO CL_DEMO_RAP_EML_READ

ABAP_DESCRIPTION
Access with ABAP using EML
The above source code uses EML to access the RAP business object from an ABAP class:
READ ENTITY bdef Two read operations are executed with the statement READ ENTITY for single entities. The one for the root entity, the other for the child entity using a read-by-association operation. The mandatory results of the read operations are stored in an internal table which is declared inline. In doing so, the internal table gets the required BDEF derived type. The RAP query engine reads the data from the respective database tables into a managed transactional buffer in which the read operations take place using the ALL FIELDS WITH addition.
READ ENTITIES OF bdef Multiple operations are executed on multiple RAP BO entities. In this case, read operations on the root entity, the child entity directly (mentioning the alias name defined in the BDEF) as well as a read-by-association operation (here, it is the association to the child entity) are covered.
READ ENTITIES OPERATIONS dynop The example demonstrates a dynamic read operation on the root entity and a dynamic read-by-association operation on the child entity. For that purpose, an internal table with type ABP_BEHV_RETRIEVALS_TAB must be defined. This table includes specific parameters that must be filled, among others, references to other internal tables holding components according to which the dynamic read operation should be carried out.