Get Example source ABAP code based on a different SAP table
Using %data> / %target> This example demonstrates the use of %data> and %target> with a managed> RAP BO >. Data model> The CDS data model consists of the root entity DEMO_MANAGED_ROOT_4 > and its child entity DEMO_MANAGED_CHILD_4>. Root entity: DDLS DEMO_MANAGED_ROOT_4 Child entity: DDLS DEMO_MANAGED_CHILD_4 Behavior definition> The RAP behavior definition> DEMO_MANAGED_ROOT_4>> is defined in RAP BDL> as follows: BDEF DEMO_MANAGED_ROOT_4 Behavior implementation> For the above RAP behavior definition, one ABP> is created. The global class of the behavior pool is BP_DEMO_MANAGED_ROOT_4>>. The actual behavior implementation takes place in local classes that are defined and implemented in the BP_DEMO_MANAGED_ROOT_4========CCIMP>> of the behavior pool. In this case, the behavior pool does not include any implementations that are relevant for the example.
ABAP_SOURCE_CODE DEMO CL_DEMO_RAP_DRVD_TYPES_DATA
ABAP_DESCRIPTION Access with ABAP using EML> There is one ABAP_EML modify request that covers several RAP modify operations: The first ABAP_EML modify operation is a RAP create operation that creates two RAP BO instances> for the root entity. The first instance is created by specifying the key and data fields with %data> individually with the structure component selector >. The second instance is created by specifying %data> with the VALUE>>. In principle, the use of %data> is optional. For example, the data fields can be specified directly without %data>. The second ABAP_EML modify operation is a create-by-association focusing on the %target> component. Two RAP BO instances are created for the child entity. The reference to instances from the root entity is made via %cid_ref>>. Also here, the key and data fields of the instance that is to be created for the child entity within %target> are specified using %data > which is optional in this case, too. The third ABAP_EML modify request is an update operation. It just shows the optional use of %data> when referring to key and data fields. With a COMMIT ENTITIES>> statement, the instances are saved to the database. The output shows the database table entries of the root and child entity.