SAP EML MODIFY OP FIELDS ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_EML - MODIFY, Field Specification Expressions
This example demonstrates various standard operations and variants of field specification expressions to set up internal tables for ABAP_EML MODIFY ENTITY statements to manipulate a simple managed RAP BO.
The following standard operations and field specification alternatives are covered in the example:
Operations
CREATE
CREATE BY association
UPDATE
DELETE
Field specification alternatives
FROM
FIELDS (...) WITH
SET FIELDS WITH
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_OPRTNS

ABAP_DESCRIPTION
Access with ABAP using EML
The above source code uses EML to access the RAP business object from an ABAP class:
Modify operations with FROM Two MODIFY ENTITY operations are executed with FROM for both root and child entity. To cover several operations in one go, four new data sets are created for the root entity of which one is updated and deleted in the same MODIFY statement. Furthermore, two data sets are created for the child entity via a create-by-association operation.
Modify operations with FIELDS (...) WITH A CREATE, CREATE BY and UPDATE operation is demonstrated within one MODIFY ENTITY statement using the addition FIELDS (...) WITH.
Modify operations with SET FIELDS WITH A CREATE, CREATE BY and UPDATE operation is demonstrated within one MODIFY ENTITY statement using the addition SET FIELDS WITH.
For demonstration purposes, several internal tables with the required BDEF derived type are created to be used with the modify operations. They include demo values to be shown in the output. The RAP framework reads the data from the respective database tables into a managed transactional buffer in which the operations take place. The changes are saved with the statement COMMIT ENTITIES, and, thus, the changed data are persisted to the database tables.