Ansicht
Dokumentation

ABENBDL_DETERMINATION_ABEXA - BDL DETERMINATION ABEXA

ABENBDL_DETERMINATION_ABEXA - BDL DETERMINATION ABEXA

General Data in Customer Master   Vendor Master (General Section)  
This documentation is copyright by SAP AG.
SAP E-Book

- Determination

This example demonstrates how determinations are defined, implemented, and consumed in a managed RAP BO.

Data model

The CDS data model consists of the root entity DEMO_SALES_CDS_SO_2 and its child entity DEMO_SALES_CDS_SO_I_2. The root entity represents a sales order and the child entity represents a sales order item.

Root entity:

Child entity:

Behavior definition

The CDS behavior definition DEMO_SALES_CDS_SO_2 is defined in CDS BDL as follows:

Definition of determinations

The following determinations are defined in the root entity:

  • setID is a determination on save that is triggered whenever a new instance of the root entity is created. It 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.
  • 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 determination on modify:

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

Behavior implementation

For the above CDS behavior definition, one ABAP behavior pool (ABP) is created. The global class of the behavior pool is BP_DEMO_SALES_CDS_SO_2. The actual implementation takes place in the BP_DEMO_SALES_CDS_SO_2========CCIMP and it works as follows:

  • setID generates a random value of type i for the field SalesOrderId of each BO instance.
  • setStatustoNew inserts the value O for Open into column Status for each newly created BO instance.
  • TotalPrice reads the fields GrossAmount and Quantity from the child entity via a read-by-association operation. It first calculates the total price per item and then sums up the prices of all items for each sales order to get the overall price.
  • TotalPrice_1 works exactly like TotalPrice, but it has different trigger conditions.

Source Code

Execute

Description

Access with ABAP using EML

The above source code uses EML to access the RAP business object from an ABAP program:

  • Two BO instances are created with the statement MODIFY ENTITY. Two child entities are created for each root entity instance so both sales orders have two sales order items.
  • All three determinations of the root entity are triggered by the creation of new instances and they insert values into the fields ID, LIFECYCLE_STATUS, and AMOUNT_SUM.
  • The technical key field SO_KEY is filled by means of internal numbering.





BAL_S_LOG - Application Log: Log header data   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.

Length: 5559 Date: 20240424 Time: 061140     sap01-206 ( 83 ms )