SAP-samples / abap-platform-fiori-feature-showcase

Feature showcase that demonstrates and documents how to implement annotation-driven SAP Fiori Elements UI features for oData V4, using the ABAP RESTful Application Programming Model (RAP).
Apache License 2.0
162 stars 36 forks source link

Side effects are not working for messages #11

Closed koradaramjee789 closed 1 year ago

koradaramjee789 commented 1 year ago

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

    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
    }
  4. Use side effects in Projection Behavior
  5. Test the application by select a begin date that is supposed to give error.
  6. 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.

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;
    }

}

Best wishes, Ramjee Korada

jessie-cheah commented 1 year ago

Already answered in https://answers.sap.com/questions/13941873/abap-rap-side-effects-are-not-working-for-messages.html