SAP BDL DET ACTION EXT ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_RAP - Extend Determine Action
This example demonstrates how a determine action is extended via a BDEF extension.
Data model
The CDS data model consists of the root entity DEMO_RAP_EXTENSIBILITY_DET_ACT and its child entity DEMO_RAP_EXT_DET_ACT_CHILD.
Root entity:
DDLS DEMO_RAP_EXTENSIBILITY_DET_ACT
CDS transactional interface, root entity:
DDLS DEMO_RAP_EXT_DET_ACT_INT
Child entity:
DDLS DEMO_RAP_EXT_DET_ACT_CHILD
CDS transactional interface, child entity:
DDLS DEMO_RAP_EXT_DET_ACT_INT_CH
Behavior definition
The RAP behavior definition DEMO_RAP_EXTENSIBILITY_DET_ACT is defined in RAP BDL as shown below. It defines the determine action trigger_all, which triggers two determinations. The behavior definition is extensible and explicitly allows extensions to the determine action trigger_all.
BDEF DEMO_RAP_EXTENSIBILITY_DET_ACT
RAP BO interface
The following RAP BO interface is used as stable public interface for extensions.
BDEF DEMO_RAP_EXT_DET_ACT_INT

Behavior extension
The BDEF extension DEMO_RAP_DET_ACT_EXT extends the determine action trigger_all by adding a new determination on save.
BDEF DEMO_RAP_DET_ACT_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_EXTENSIBILITY_DET_, see BP_DEMO_RAP_EXTENSIBILITY_DET_CCIMP. This global class implements three methods:
get_instance_authorizations: Checks the value of field CompanyCode. If the company code is ABCD, update requests are not allowed. If the company code has any other value , updates are allowed.
setID: determination on save that inserts a randomly generated integer into field SalesOrderId.
TotalPrice: determination on save that multiplies the number of sales order items with the price and adds the result of all categories, thus calculating the total price of all items of a sales order.
For the RAP extension behavior definition, one ABAP behavior pool (ABP) is created. The global class of the behavior pool is BP_DEMO_RAP_DET_ACT_EXT, see BP_DEMO_RAP_DET_ACT_EXT=======CCIMP. This global class implements the determination setStatustoNew. When called, this determination inserts value O (meaning open), into the field Status.
ABAP_NOTE This is a simple example that serves demonstration purposes.

ABAP_SOURCE_CODE
DEMO CL_DEMO_CDS_EXT_DET_ACT

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:
It inserts two parent instances and two child instances directly into the database tables using AB_SQL INSERT . This is done to avoid triggering the determinations (all three of them are triggered by EML MODIFY ENTITIES CREATE).
It executes the determine action trigger_all.
Using the AB_SQL SELECT statement, the content of the parent table before and after executing the determine action is displayed. The fields SalesOrderId, AmountSum, and Status have values that were inserted via the determinations.
The RAP framework executes the implementations in the original and extension ABAP behavior pools in the following order:
get_instance_authorizations: Checks whether the operation on the root node is authorized.
setID, a determination from the root node of the original BDEF.
setStatustoNew, a determination from the root node extension.
get_instance_authorizations: Checks whether the operation on the child node is authorized.
TotalPrice, a determination from the child node of the original BDEF.