ABAP for Cloud Development
AS ABAP Release 914, ©Copyright 2024 SAP SE. All rights reserved.
ABAP - Keyword Documentation → ABAP RAP Business Objects → RAP - Behavior Definitions → RAP - BDL for Behavior Definitions → RAP - Managed and Unmanaged Behavior Definitions → RAP - EntityBehaviorDefinition → RAP - EntityBehaviorBody → RAP - RAP BO Operations →
RAP - determine action
Syntax
internal determine action
(authorization:none
authorization:update
authorization:global
authorization:instance)
DetermineActionName extensible
{
determination (always) MyDetermination1;
determination (always) MyDetermination2;
validation (always) MyValidation1;
validation (always) MyValidation2;
determination (always) Child~ChildDetermination;
validation (always) Child~ChildValidation;
...
}
Description
Determine actions allow the RAP BO consumer to execute determinations and validations on request. Whenever a determine action is executed, the determinations and validations assigned to it are evaluated and then only those determinations and validations are executed whose trigger conditions are fulfilled.
A determine action can include on-save determinations and validations. On-modify determinations are not allowed. The determinations and validations are specified within curly brackets { }
and they are separated by semicolons (;
). It is possible to specify a determine action without any determinations and validations. Determinations and validations of child entities can be included using the syntax child~childDetermination
or child~childValidation
, as long as these validations and determinations do not include the trigger operation delete
.
If the optional addition always
is used, then all determinations and validations that are part of the determine action are executed regardless of their trigger conditions. After a determination with the flag always
has been executed, it can be triggered again by other determinations belonging to the same determine action.
Execution order: Determinations are executed first, validations afterwards. The execution order among determinations or validations themselves is defined by the RAP framework and is independent of the specified order within the determine action.
The following RAP BDL operation additions are possible:
internal
to make the respective determine action accessible only from within the business object implementation.authorization:none
excludes the operation in question from authorization checks.authorization:update
delegates the authorization control to the authorization check that is implemented for the update operation.authorization:global
replaces the authorization control that is specified in the authorization master entity and applies global authorization checks instead.authorization:instance
replaces the authorization control that is specified in the authorization master entity and applies instance authorization checks instead.- A determine action can be declared as extensible using the addition
extensible
. This makes it possible to add validations or determinations to the determine action in question via a BDEF extension. - Note: A determine action can be declared as
extensible
only if the following prerequisites are met: The RAP BO must allow for extensions and the RAP BO must be draft-enabled. For further details on extensibility enabling, see the topic RAP - Extensibility Enabling for Base BOs.
Availability
- Managed RAP BOs: In a managed RAP BO, determine actions do not require an implementation in the ABAP behavior pool (ABP), but the determinations and validations included in a determine action must be implemented.
- Unmanaged and draft-enabled RAP BOs: In an unmanaged RAP BO, determine actions require an implementation in the RAP handler method
FOR MODIFY ... ACTION
in the ABAP behavior pool. - Caution: Not available for unmanaged, non-draft RAP BOs.
- In a projection BO, determine actions from the base BDEF can be reused using the syntax
use action
. For details on reuse, see the topic RAP -use
, Projection and Interface BDEF. - In a RAP BO interface, determine actions from the base BDEF can be reused using the syntax
use action
. For details on reuse, see the topic RAP -use
, Projection and Interface BDEF.
Hint
The draft determine action Prepare
is the draft pendant to determine actions. It is documented in topic RAP BDL - draft actions.
Further Information
Development guide for the ABAP RESTful Application Programming Model, topic Action Definition.
Example
The following example shows a managed BDEF based on the on the CDS root view entity DEMO_SALES_CDS_SO_3
. The root view entity represents a sales order and the child entity represents a sales order item. The determine action trigger_all
includes the following two determinations, one from in the root entity and one from the child entity:
setID
assigns values to the semantic key fieldSalesOrderId
during the save sequence whenever a new entity instance is created.TotalPrice
sums up the price of all items of a sales order. It is triggered whenever a new sales order is created.
managed implementation in class bp_demo_sales_cds_so_3 unique;
strict(2);
define behavior for DEMO_SALES_CDS_SO_3 alias SalesOrder
persistent table demo_sales_order
lock master
authorization master (global)
{
create;
update;
association _SalesOrderItem { create; }
field(readonly:update) SoKey;
determination setID on save { create; }
determine action trigger_all
{
determination ( always ) setID;
determination ( always ) SalesOrderItem ~ TotalPrice;
}
mapping for DEMO_SALES_ORDER
{
SoKey = so_key;
SalesOrderId = id;
BuyerId = buyer_id;
Status = lifecycle_status;
ShipToId = ship_to_id;
QuantitySum = quantity_sum;
UomSum = uom_sum;
AmountSum = amount_sum;
CurrencySum = currency_sum;
CompanyCode = company_code;
CreatedBy = created_by;
CreatedAt = created_at;
CreatedOn = created_on;
LastChangedBy = last_changed_by;
LastChangedOn = last_changed_on;
LastChangedAt = last_changed_at;
}
}
define behavior for DEMO_SALES_CDS_SO_I_3 alias SalesOrderItem
persistent table demo_sales_so_i
lock dependent by _SalesOrder
authorization dependent by _SalesOrder
{
update;
delete;
field ( readonly : update ) ParentKey;
determination TotalPrice on save { create; }
association _SalesOrder { }
field(readonly:update) SoItemKey;
mapping for DEMO_SALES_SO_I corresponding
{
SoItemKey = so_item_key;
ParentKey = parent_key;
GrossAmount = gross_amount;
}
}
The determinations are implemented in the behavior pool BP_DEMO_SALES_CDS_SO_3
.
The class CL_DEMO_CDS_DETERMINE_ACTION
accesses the business object using EML and carries out the following steps:
- It first inserts data into the BO's persistent database tables using ABAP SQL. That means that BO entity instances are available in the database, but the determinations haven't yet been triggered.
- The determine action
trigger_all
is executed with the statementMODIFY ENTITIES
for two entity instances. For these two entity instances, the fieldsID
andTotalPrice
are determined. - Code snippet:
MODIFY ENTITIES OF demo_sales_cds_so_3
ENTITY SalesOrder
EXECUTE trigger_all
FROM VALUE #( ( sokey = '0894EF1643A01EDB90EE45FBFB0C7DAA' )
( sokey = '0894EF1643A01EDB90EE45FBFB0C9DAA' ) )
MAPPED FINAL(mapped)
FAILED FINAL(failed)
REPORTED FINAL(reported).
COMMIT ENTITIES.
- The determined values are committed to the database with the statement
COMMIT ENTITIES
.
Result: values for the fields ID
and TotalPrice
are determined.