What does it do? A determination> modifies instances of RAP business objects> based on trigger conditions. A determination is implicitly invoked by the RAP framework> if the trigger condition of the determination is fulfilled. Trigger conditions can be modify operations> ( create, update, delete >) CUD1; CUD2; ...>, or modified fields Field1; Field2; ... >. Two types of determinations are distinguished, depending on the stage of the program flow the determination is executed: on modify > determinations and on save> determinations. A determination can compute data, modify entity instances, and return messages. Determinations can be carried out at different points in time during the program logic:
on modify> The determination is executed immediately after data changes take place in the transactional buffer> so that the result is available during the transaction. Determinations on modify must be implemented in the RAP handler method> FOR DETERMINE>> in the local ABAP behavior pool>.
on save> The determination is executed during the save sequence> at the end of an transaction, when changes from the transactional buffer are persistent on the database. Determinations on save must be implemented in the RAP handler method> FOR DETERMINE>> in the local ABAP behavior pool>.
Trigger Conditions There can be one or more trigger conditions. The trigger conditions can be changes of field values or the execution of one of the standard operations> create>, update>, or delete>.
create>: determination is executed when an instance is created.
update>: determination is executed when an instance is updated. For determinations defined as on save>, update works only in combination with the trigger operation create>.
delete>: determination is executed when an instance is deleted.
field>: determination is executed when the value of the specified field(s) field1, field2, ...> are changed by a create or update operation. The fields that are used for the trigger conditions must belong to the same entity the determination is assigned to. ABAP_NOTE If a field is tagged with the RAP field characteristic> notrigger$[:warn$]>>, it must not be used in a trigger condition.
ABAP_AVAILABILITY
Managed RAP BOs>
Unmanaged> and draft-enabled> RAP BOs. ABAP_CAUTION Not available for unmanaged, non-draft RAP BOs. In unmanaged RAP BOs>, determinations are only supported for draft instances, not for active instances.
Projection BOs> ABAP_AVAILABILITY_END
ABAP_FURTHER_INFO Development guide for the ABAP RESTful Application Programming Model, section about Determinations>.
Latest notes:
The determination result must not change if the determination is executed several times under the same conditions (idempotence).
The execution order of determinations is not fixed. If there is more than one determination triggered by the same condition, the execution order is arbitrary.
Once a determination has been triggered, it must run independently from other determinations.
If an instance is created and deleted with the same request, it can happen that an EML> read operation in a determination defined as on modify> fails as instances with the given key cannot be found. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The following example shows a managed BDEF based on the CDS root view entity DEMO_SALES_CDS_SO_2>>. The root view entity represents a sales order and the child entity DEMO_SALES_CDS_SO_I_2>> represents a sales order item. Three determinations are defined in the RAP BO root entity>:
setID> assigns values to the semantic key field SalesOrderId > during the save sequence. The technical key field SoKey> is populated by means of internal numbering using the statement numbering:managed>>.
setStatustoNew> sets the status of a newly created sales order to O> for open>. It is triggered whenever a new sales order is created. This status can be changed to Accepted> or Rejected > during further processing.
TotalPrice> sums up the price of all items of a sales order. It is triggered whenever a new sales order is created. The child entity defines one on modify> determination:
TotalPrice_1> is the counterpart to TotalPrice>. If a sales order is created without any items, then this determination ensures that the overall price of a sales order is calculated as soon as sales order items are added. BDEF DEMO_SALES_CDS_SO_2 The determinations are implemented in the behavior pool BP_DEMO_SALES_CDS_SO_2>, see BP_DEMO_SALES_CDS_SO_2========CCIMP>>. The class CL_DEMO_CDS_DETERMINATION>> accesses the business object using EML>. It creates two BO instances, providing only a value for the field BuyerID> for each. Code snippet: ABEXA 01534 Result: The values for the fields so_key>, id>, lifecycle_status>, and amount_sum> are determined by the RAP framework. IMAGE ABDOC_DETERMINATION.png 630 114 ABAP_EXAMPLE_END
ABAP_EXAMPLE_ABEXA The example above is explained in detail in the executable example RAP BDL - determination >. ABAP_EXAMPLE_END