Get Example source ABAP code based on a different SAP table
ABAP_EML - MODIFY AUGMENTING ENTITY> This example demonstrates the ABAP_EML MODIFY> statement with the addition AUGMENTING> with a RAP projection business object. Base BDEF> The base BDEF is the managed RAP behavior definition DEMO_MANAGED_ROOT_WAS>. It defines the behavior for two entities which are connected via a CDS composition relation. BDEF DEMO_MANAGED_ROOT_WAS Projection BDEF> The projection BDEF reuses the standard operations from the base BDEF and augments the create>, update>, and create-by-association> operations. BDEF DEMO_MANAGED_ROOT_PROJ Behavior implementation> For the above projection BDEF, one behavior pool> is created. The global class of the behavior pool is BP_DEMO_MANAGED_ROOT_PROJ>>. The actual behavior implementation takes place in local classes that are defined and implemented in the BP_DEMO_MANAGED_ROOT_PROJ=====CCIMP>> of the behavior pool. In the behavior pool, operation augmentation is implemented in the following methods:
augment_create> Augments an original base instance for the operation create>. Whenever new instances are created, the value of field field1 > is set to create_augment>.
augment_update> Augments an original base instance for the operation update>. Whenever an existing entity instance is updated, the value of field field4> is set to 222>.
augment_cba_child> Augments an original base instance for the operation create by association>. Whenever new child instances are created via the parent entity, the value of field field2 > is set to cba_augment>.
ABAP_DESCRIPTION Access with ABAP using EML> The above source code uses EML> to access the RAP business object from an ABAP class:
Using an ABAP_EML MODIFY> statement, two parent entity instances are created. In the same request, one of the created instances gets updated. The operation augmentation automatically adds the value create_augment> for field field1> for each entity instance. For the updated entity instance, field4> is set to 222>.
With a further ABAP_EML MODIFY> statement, a child entity instance for each parent entity instance is created via a create-by-association operation. The operation augmentation automatically adds the value cba_augment> for field field2> for each newly created child entity instance.
The output window shows the database entries of the root and child entities' tables.