Ansicht
Dokumentation

ABENBDL_DETERMINATIONS - BDL DETERMINATIONS

ABENBDL_DETERMINATIONS - BDL DETERMINATIONS

PERFORM Short Reference   BAL Application Log Documentation  
This documentation is copyright by SAP AG.
SAP E-Book

- determination

determination DetName ${on modify { CUD1; CUD2; ... }
                               $| { field Field1, Field2, ... ; }$}
                     $|${on save   { CUD1; CUD2; ... }
                               $| { field Field1, Field2, ... ; }$}


Effect

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.

Availability

Not available for unmanaged, non-draft RAP BOs.
In unmanaged RAP BOs, determinations are only supported for draft instances, not for active instances.

Development guide for the ABAP RESTful Application Programming Model, section about Determinations.

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 can't be found.

Example

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

The determinations are implemented in the behavior poolBP_DEMO_SALES_CDS_SO_2, see BP_DEMO_SALES_CDS_SO_2========CCIMP.

The program 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:

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@@

The example above is explained in detail in the executable example CDS BDL - determination.






SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.

Length: 10677 Date: 20240329 Time: 150249     sap01-206 ( 120 ms )