Get Example source ABAP code based on a different SAP table
ABAP_EML - MODIFY>, Variants This example demonstrates the variants of the ABAP_EML MODIFY> statement to manipulate a simple managed RAP BO >:
MODIFY ENTITY bdef>
MODIFY ENTITIES OF bdef>
MODIFY ENTITIES OPERATIONS op_tab> Data model> The CDS data model consists of the root entity DEMO_MANAGED_ROOT> and its child entity DEMO_MANAGED_CHILD>. Root entity: DDLS DEMO_MANAGED_ROOT Child entity: DDLS DEMO_MANAGED_CHILD Behavior definition> The RAP behavior definition> DEMO_MANAGED_ROOT>> is defined in RAP BDL> as follows: BDEF DEMO_MANAGED_ROOT Behavior implementation> For the above RAP behavior definition, there is no ABAP behavior pool (ABP)> created and needed since only standard CRUD> operations are used in the example.
ABAP_SOURCE_CODE DEMO CL_DEMO_RAP_EML_MODIFY
ABAP_DESCRIPTION Access with ABAP using EML> The above source code uses EML> to access the RAP business object from an ABAP class:
MODIFY ENTITY bdef> Two create operations are executed with the statement MODIFY ENTITY > for single entities. The one for the root entity, the other for the child entity. For that purpose, two internal tables with the required BDEF derived type> are created. They include demo values to be shown in the output. The RAP query engine reads the data from the respective database tables into a managed transactional buffer> in which the create operations take place using the SET FIELDS> additions. The changes are saved with the statement COMMIT ENTITIES>> , and, thus, the changed data are persisted to the database tables.
MODIFY ENTITIES OF bdef> Multiple operations are executed on multiple RAP BO entities. In this case, the following is demonstrated: an update and create operation on data sets of the root entity, a create by association operation and an update operation on the child entity directly. The addition SET FIELDS> is used while the internal tables are created inline holding demo data.
MODIFY ENTITIES OPERATIONS op_tab> The example demonstrates a dynamic modify operation. There are various operations on data sets of the root and child entity. For that purpose, an internal table with type ABP_BEHV_CHANGES_TAB>> must be defined. This table includes parameters (in this case, among others, other tables holding demo data and being typed with the required BDEF derived type) to carry out the modifications.