Get Example source ABAP code based on a different SAP table
ABAP_EML - 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>. Root entity: DDLS DEMO_MANAGED_ROOT_CUSTOM Child entity: DDLS DEMO_MANAGED_CHILD_CUSTOM Behavior definition> The RAP behavior definition> DEMO_MANAGED_ROOT_CUSTOM>> is defined in RAP BDL> as follows: BDEF DEMO_MANAGED_ROOT_CUSTOM 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 RAP 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.
ABAP_SOURCE_CODE DEMO CL_DEMO_RAP_CUSTOM_OP_M
ABAP_DESCRIPTION Access with ABAP using EML> The above source code uses EML> to access the RAP business object from an ABAP class:
As initial step in the example, 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.