Ansicht
Dokumentation

ABENEML_MODIFY_CUSTOM_OP_ABEXA - EML MODIFY CUSTOM OP ABEXA

ABENEML_MODIFY_CUSTOM_OP_ABEXA - EML MODIFY CUSTOM OP ABEXA

BAL Application Log Documentation   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

- MODIFY, Nonstandard Operations

This example demonstrates This example demonstrates how a MODIFY statement can be used to access a managed RAP BO and execute an action. The scenario is a simple calculation based on existing values in two columns of a table whose result is inserted in another column.

Data model

The CDS data model consists of the root entity DEMO_MANAGED_ROOT_CUSTOM and its child entity DEMO_MANAGED_CHILD_CUSTOM. Furthermore, it contains an association to an entity (DEMO_MANAGED_ASSOC_CUSTOM) that is not part of the composition tree.

Root entity:

Child entity:

Behavior definition

The CDS behavior definition DEMO_MANAGED_ROOT_CUSTOM is defined in CDS BDL as follows:

Action definition

The action calculate triggers a calculation based on the respective math symbol to be inserted by a user. The action has the output parameter $self with cardinality 1. In doing so, the parameter result returns the same entity instance for which the action is executed.

Behavior implementation

For the above CDS behavior definition, one ABAP behavior pool (ABP) is created. The global class of the behavior pool is BP_DEMO_MANAGED_ROOT_CUSTOM. This global class implements the local handler class LHC_DEMO_MANAGED_ROOT_CUSTOM, which contains the calculate method to implement the action. The actual implementation takes place in the BP_DEMO_MANAGED_ROOT_CUSTOM===CCIMP:

  • The existing values of two columns are read using a READ EML statement into the transactional buffer so as to get the numbers for which the calculation is to be carried out.
  • Depending on the math symbol provided, the calculation is carried out.
  • Using a MODIFY EML statement, the fields of a third column are updated with the result of the calculation.
  • The output parameter result is finally filled so that the calculation result can be displayed in the column.

Source Code

Execute

Description

Access with ABAP using EML

The above source code uses EML to access the RAP business object from an ABAP program:

  • As initial step in the program, the user is prompted to insert a math symbol on whose basis the calculation is done.
  • Using a MODIFY statement, demo values (that is, numbers for the calculation) are created. These values are displayed after they were read from the RAP BO instance using a READ statement.
  • The action calculate is executed on the instance with the statement EXECUTE using the math symbol that has been provided.
  • The result, failed, and reported parameters are returned.
  • The changes that were performed by the action in the transactional buffer are committed to the database with a COMMIT ENTITIES statement.
  • A SELECT statement is finally used to read the changed data from the persistent table DEMO_TAB_ROOT_2 to fill the output table. As a result of the action, the third column is filled with the calculation result.





PERFORM Short Reference   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.

Length: 5149 Date: 20240424 Time: 071401     sap01-206 ( 51 ms )