SAP BDL USING INTERFACE ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_RAP - RAP BO Extension Using Interface
This example demonstrates a RAP BO extension via a RAP BO interface.

Base 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.

RAP BO Interface
CDS data model projection
Root node projection:
DDLS DEMO_RAP_EXT_USING_INTERFACE
Child node projection:
DDLS DEMO_RAP_EXT_USING_INT_CHILD
Projection of grandchild node:
DDLS DEMO_RAP_EXT_USING_INT_GRCHLD
Projection of great-grandchild node:
DDLS DEMO_RAP_EXT_USING_INT_GGCHLD
RAP interface behavior definition
The following interface BDEF projects the base RAP BO.
BDEF DEMO_RAP_EXT_USING_INTERFACE

BDEF Extension
The BDEF extension DEMO_RAP_EXT_USING_INTERF extends the RAP BO via its interface. It addresses the root node by its interface name, RootInterface. It adds one extension action to the RAP BO.
BDEF DEMO_RAP_EXT_USING_INTERF
Extension ABP
The extension action setValue_ext is implemented in the extension ABP, see BP_DEMO_RAP_EXT_USING_INTERF==CCIMP. When executed, it changes the value of field CharInt.

ABAP_SOURCE_CODE
DEMO CL_DEMO_RAP_EXT_VIA_INTERFACE

ABAP_DESCRIPTION
Access with ABAP using EML
The above source code uses AB_SQL and ABAP EML to access the RAP BO interface from an ABAP class and performs the following steps:
It creates two instances of the root entity.
It executes the action setValue_ext for one of the instances.
The content of the database table after the create operation and after the action is displayed.