SAP DERIVED TYPES CID CIDREF ABEXA



Get Example source ABAP code based on a different SAP table
  



Using %cid / %cid_ref
This example demonstrates the use of %cid and %cid_ref with a managed RAP BO . Furthermore, it includes the use of the addition AUTO FILL CID with a RAP create operation.
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_CID

ABAP_DESCRIPTION
Access with ABAP using EML
There are two ABAP_EML modify requests that cover multiple RAP modify operations: With a RAP create operation, multiple RAP BO instances are created that include user-defined content IDs %cid. In the same ABAP_EML request, a create-by-association operation creates RAP BO instances for the child entity while using %cid_ref to refer to the instances that have just been created for the root entity. The RAP BO instances for the child also include content IDs %cid which are not referred to in the example. This operation is followed by an update and delete operation in the same request. Both operations use %cid_ref to refer to the instances that have just been created, too. With a COMMIT ENTITIES statement, the instances are saved to the database. The output shows the database table entries as well as the mapped responses for root and child entity to visualize the mapping of %cid and the keys. For demonstration purposes, the example also covers the use of AUTO FILL CID in a RAP create and create-by-association operation. When specifying the create operation with the addition AUTO FILL CID, %cid is filled automatically. With a COMMIT ENTITIES statement, the instances are saved to the database. The output shows the database table entries - including the entries from the first ABAP_EML modify request - as well as the mapped responses for root and child entity.