Skip to Content
1
Aug 03, 2023 at 08:45 AM

ABAP RAP : Side effects are not working for messages

431 Views Last edit Aug 06, 2023 at 08:52 AM 2 rev

Hi,

I am trying to explore side effects that shows error message immediately on entering the field input. But it is not reflecting in OData v2 or V4.
Please see below link.

Determine action executed on field affects messages

Steps followed:

  1. Define and implementation for validation
    validation Valid_Dates on save { create; update; field BeginDate; }
  2. Define determine action
    determine action Det_act_valid_dates { validation Valid_Dates; }
  3. Define Side effects
<code>side effects
  {
    determine action Det_act_valid_dates executed on field BeginDate affects messages;  " This is not working

    field BookingFee affects field TotalPrice;  " This works fine
  }
  1. Use side effects in Projection Behavior
  2. Test the application by select a begin date that is supposed to give error.
  3. Actual result : it does not give error on change of the field input but gives me error only on SAVE.

Not sure if there are additional prerequisites are there. Can you please help in resolving the issue.
Please see the complete code.

<code>managed implementation in class ZRK_SDE_BP_TRAVEL unique;
strict ( 2 );
with draft;

define behavior for ZRK_SDE_I_TRAVEL alias Travel
persistent table zrk_sde_a_travel
draft table zrk_sde_d_travel
etag master LocalLastChangedAt
lock master total etag LastChangedAt
authorization master ( global )

{

  create;
  update;
  delete;
  association _Booking { create; with draft; }

  draft action Edit;
  draft action Activate;
  draft action Discard;
  draft action Resume;
  draft determine action Prepare;

  field ( readonly )
  TravelUUID,
  TravelID,
  OverallStatus,
  TotalPrice,
  LocalCreatedAt,
  LocalCreatedBy,
  LastChangedAt,
  LocalLastChangedAt,
  LocalLastChangedBy;



  field ( numbering : managed )
  TravelUUID;

  determination Set_Travel_no on save { create; }

  validation Valid_Dates on save { create; update; field BeginDate; }
  determination Calculate_Total_price on modify { field BookingFee; }
  determine action Det_act_valid_dates { validation Valid_Dates; }

  internal action ReCalcTotalPrice;

  side effects
  {
    determine action Det_act_valid_dates executed on field BeginDate affects messages;

    field BookingFee affects field TotalPrice;
  }
  mapping for zrk_sde_a_travel
    {
      TravelUUID         = travel_uuid;
      TravelID           = travel_id;
      AgencyID           = agency_id;
      CustomerID         = customer_id;
      BeginDate          = begin_date;
      EndDate            = end_date;
      BookingFee         = booking_fee;
      TotalPrice         = total_price;
      CurrencyCode       = currency_code;
      Description        = description;
      OverallStatus      = overall_status;
      LocalCreatedBy     = local_created_by;
      LocalCreatedAt     = local_created_at;
      LocalLastChangedAt = local_last_changed_at;
      LocalLastChangedBy = local_last_changed_by;
      LastChangedAt      = last_changed_at;
    }



}

define behavior for zrk_sde_i_booking alias Booking
persistent table zrk_sde_a_book
draft table zrk_sde_d_book
lock dependent by _Travel
authorization dependent by _Travel
etag master localLastChangedAt

{


  field ( numbering : managed )
  BookingUuid;

  update ( features : instance );
  delete ( features : instance );
  field ( readonly ) BookingUuid, TravelUUID;
  association _Travel { with draft; }

  // determination for calculation of total flight price
  determination calculate_Total_Price on modify { create; delete; field flightprice; }
  action Apply_Discount parameter zrk_sde_a_apply_disc result [1] $self;

  side effects
  {

    field FlightPrice affects field _Travel.TotalPrice;
    action Apply_Discount affects field _Travel.TotalPrice;
  }
  mapping for zrk_sde_a_book
    {
      BookingUuid  = booking_uuid;
      TravelUUID   = parent_uuid;
      BookingId    = booking_id;
      BookingDate  = booking_date;
      CustomerId   = customer_id;
      CarrierId    = carrier_id;
      ConnectionId = connection_id;
      FlightDate   = flight_date;
      FlightPrice  = flight_price;
      CurrencyCode = currency_code;
    }



}

Behavior Projection:

projection implementation in class ZRK_BP_SDE_C_TRAVEL unique;
strict ( 2 );
use draft;
use side effects;
define behavior for ZRK_SDE_C_TRAVEL alias Travel
use etag

{
  use create;
  use update;
  use delete;
  use association _Booking { create ; with  draft;}

  use action Edit;
  use action Activate;
  use action Discard;
  use action Resume;
  use action Prepare;

}

define behavior for zrk_sde_c_booking alias Booking

use etag

{
  use update;
  use delete;

  use action Apply_Discount ;
  use association _Travel { with draft; }

}

Best wishes,

Ramjee Korada