Get Example source ABAP code based on a different SAP table
ABAP_RAP - Node Extension This example demonstrates how to add an extension node with behavior to a RAP BO.
Original RAP BO Data model> The CDS data model consists of four nodes which form a hierarchical CDS composition tree. They are connected via CDS compositions. Root entity: DDLS DEMO_RAP_EXTENSIBLE_ROOT Child entity: DDLS DEMO_RAP_EXTENSIBLE_CHILD Grandchild entity: DDLS DEMO_RAP_EXTENSIBLE_GRCHLD Great-grandchild entity: DDLS DEMO_RAP_EXTENSIBLE_GGCHLD Behavior definition> The RAP behavior definition> DEMO_RAP_EXTENSIBLE_ROOT>> is defined in RAP BDL> as shown below. It defines a managed, draft-enabled RAP BO with multiple extension points. BDEF DEMO_RAP_EXTENSIBLE_ROOT Behavior implementation> For the RAP behavior definition, one ABAP behavior pool (ABP)> is created. The global class of the behavior pool is BP_DEMO_RAP_EXTENSIBLE_ROOT>>, see BP_DEMO_RAP_EXTENSIBLE_ROOT===CCIMP>>. It implements the method get_instance_authorizations> for instance authorization control. It returns information on whether update and delete operations are allowed on instances. In this example, these operations are not allowed if CharField> has a particular value. ABAP_NOTE This is a simple example that serves demonstration purposes.
Extension RAP BO CDS data model extension> One extension node is added to the RAP BO on the hierarchy level of the great-grandchild: DEMO_RAP_EXTENSIBLE_EXT >>. It defines associations to all four original nodes. DDLS DEMO_RAP_EXTENSIBLE_EXT The direct parent entity of the extension node DEMO_RAP_EXTENSIBLE_GRCHLD>> is extended. The extension defines and exposes a composition association to the extension node. DDLS DEMO_RAP_CDS_EXT_1 BDEF extension>
The BDEF extension DEMO_RAP_EXTENSION_1>> adds the extension node to the RAP BO. It adds behavior to the extension node with the define behavior for> syntax. It uses the syntax ancestor association> for all associations except the one that leads to the direct parent node. BDEF DEMO_RAP_EXTENSION_1
ABAP_SOURCE_CODE DEMO CL_DEMO_RAP_NODE_EXTENSION
ABAP_DESCRIPTION Access with ABAP using EML> The above source code uses AB_SQL and ABAP EML> to access the RAP business object> from an ABAP class and performs the following steps:
It performs a deep create, that means, it creates an instance of each entity of the composition tree, including the extension node.
It performs an update operation on the extension node. The instance authorization control for update operations, which is implemented in the ABP of the extended RAP BO, is checked and the update operation succeeds.
All five database tables used to store the entity data are displayed.