Get Example source ABAP code based on a different SAP table
ABAP_EML - READ>, Operation Executing Functions This example demonstrates how a READ> statement can be used to access a managed RAP BO and execute a function. In this case, a selected set of fields is read from a RAP BO entity by executing a function. 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>>. In the example, the FunctionResultEntity> method comprises an ABAP EML read operation reading the values of a selected set of fields from the entity DEMO_SPFLI_FLIGHTS> according to specific keys that are specified in the internal table following the ... EXECUTE FunctionResultEntity FROM ...> statement in the report.
ABAP_DESCRIPTION Access with ABAP using EML> The above source code uses EML> to access the RAP business object from an ABAP class:
The READ> statement executes the function FunctionResultEntity > for those entity instances whose keys are specified in the internal table following the ... EXECUTE FunctionResultEntity FROM ...> statement.
The outcome of the function execution is stored in the table result >. In this case, the function FunctionResultEntity> first reads a selected set of fields from RAP BO instances>. Then, a calculation is carried out if a selected field has a certain value (the distance of a flight connection is converted to kilometers if the distance is stored as miles). The read result is then passed to the result > table.
To display the result of the read operation, an internal table is set up and filled with the values returned by the read operation.