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:

    Availability


    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 field SalesOrderId 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 statement MODIFY ENTITIES for two entity instances. For these two entity instances, the fields ID and TotalPrice are determined.
    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.

    figure