Get Example source ABAP code based on a different SAP table
ABAP_RAP - BDEF Projection Extension, Node Extension This example demonstrates how the behavior of a projection BDEF is extended by means of a projection BDEF extension.
Original Base RAP BO Data model> The CDS data model consists of one root node without child entities: DDLS DEMO_RAP_BEH_EXT CDS transactional interface> The following CDS transactional interface> is created for the root node to fulfill the RAP BO contract> requirements for RAP extensibility>. DDLS DEMO_RAP_BEH_EXT_INT Behavior definition> The RAP behavior definition> DEMO_RAP_BEH_EXT>> is defined in RAP BDL> as shown below. It defines implementation-relevant components and extension points. BDEF DEMO_RAP_BEH_EXT 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_BEH_EXT>>, see BP_DEMO_RAP_BEH_EXT===========CCIMP> >. This global class implements the following methods:
get_instance_features>: Instance feature control for the standard operation update>. If the value of field int_field1> is more than 50, updates are not allowed. If the value is equal to or smaller than 50, updates are allowed.
get_global_authorizations>: Global authorization control defines that create, update, and delete are always allowed.
Limit>: Validation that checks the value of field int_field2 >. If the value is greater than 500, the validation fails and the entity instance is not saved. Interface BDEF> The following interface BDEF> DEMO_RAP_BEH_EXT_INT>> is required as stable interface for extensions. BDEF DEMO_RAP_BEH_EXT_INT
Extension RAP BO Data model extension> A child node is added to the RAP BO: DDLS DEMO_RAP_BEH_EXT_CHILD A CDS transactional interface is created for the child node to fulfill the RAP BO contract requirements for RAP extensibility. DDLS DEMO_RAP_BEH_EXT_INT_CH A composition association is added to the root node via a CDS view entity extension on the base layer: DDLS DEMO_BEH_EXTEND The same composition association is also added on the interface layer: DDLS DEMO_RAP_INT_EXTENSION Behavior extension> The BDEF extension DEMO_RAP_BEH_EXT_CH >> extends the root node and defines behavior for the extension child node via the BDEF interface layer. BDEF DEMO_RAP_BEH_EXT_CH ABP extension> The ABP extension is implemented in the global class BP_DEMO_RAP_BEH_EXT_CH>>, see BP_DEMO_RAP_BEH_EXT_CH========CCIMP>> . This global class implements the following methods:
Extension of the parent entity>
get_global_features>: Global feature control for the action setValue>. This action can only be executed in the time period between 6 am and 10 pm (day shift).
get_global_authorizations>: The original RAP BO defines global authorization control. RAP BO operations added via an extension require their own implementation of the global authorization control. This method generally allows execution of the method setValue>. There are no access restrictions.
setValue>: Action that sets field int_field2> to value 888>.
Extension entity behavior definition for the child entity>
get_global_authorizations>: The original RAP BO defines global authorization control. For the action ActionExt>, defined in the child node, a separate implementation of the authorization control method is required. The implementation generally allows execution of the method ActionExt>. There are no access restrictions.
myDet>: Determination on modify. Sets the value of field int_field1> to 777>.
ActionExt>: Action that updates field char_field1> for all requested entity instances.
Projection Layer Data model projection> Projection of the root node: DDLS DEMO_RAP_PROJ_EXT_BEH Projection of the child node: DDLS DEMO_RAP_PROJ_EXT_BEH_CH View entity extension DEMO_RAP_VE_EXTENSION>> that establishes a composition between original root node and extended child node: DDLS DEMO_RAP_VE_EXTENSION Behavior Projection> The projection BDEF defines behavior for the root node. It declares the root node as extensible and exposes the RAP BO standard operations. BDEF DEMO_RAP_PROJ_EXT_BEH BDEF projection extension> The BDEF projection extension DEMO_RAP_PROJ_EXT_BEH_1>> extends the root node and defines behavior for the extension child node. BDEF DEMO_RAP_PROJ_EXT_BEH_1
ABAP_SOURCE_CODE DEMO CL_DEMO_RAP_PROJ_EXT
ABAP_DESCRIPTION Access with ABAP using EML> The above source code uses ABAP EML> to access the projection BO from an ABAP class:
It inserts two parent entity instances and two child entity instances.
It updates the two parent entity instances
It executes the action setValue> from the projection extension.
It executes the action ActionExt> from the extension to the original base RAP BO. The screen output includes a table that lists the execution order of handler methods of the ABAP behavior pool. This shows which methods in which order are executed when accessing the RAP BO.