Skip to Content

Implement ETag Handling For Your Factory Calendar

test
0 %
Implement ETag Handling For Your Factory Calendar
Details

Implement ETag Handling For Your Factory Calendar

March 22, 2021
Created by
December 17, 2019
Implement ETag Handling for your factory calendar.

You will learn

  • How to create ETag handling
QR code

Prerequisites

  • You need an SAP BTP, ABAP environment trial user or a license.

A draft enabled RAP business object requires a designated field to enable optimistic concurrency checks during the transition from draft to active data. This is mandatory.
To provide optimistic concurrency locking for OData consumers an additional field must be designated. This is not mandatory.
For a smoothly running application, you need both ETags. Typically a timestamp field is used.
The RAP managed framework is able to update the ETags field automatically if they are annotated with @Semantics.systemDateTime in the CDS View.


Step 1: Create ETag handling
  1. Open behavior definition ZCAL_I_HOLIDAY_XXX. Add etag master local_last_changed_at to the root entity and etag dependent by _Public_Holiday to the text entity.

    managed implementation in class zbp_cal_i_holiday_xxx unique;
    with draft;
    
    define behavior for ZCAL_I_HOLIDAY_XXX alias HolidayRoot
    persistent table zcal_holiday_xxx
    draft table zcal_d_holi_xxx
    lock master total etag last_changed_at
    //authorization master ( instance )
    etag master local_last_changed_at
    {
      create;
      update;
      delete;
    
      field ( readonly : update ) HolidayId;
    
      association _HolidayTxt { create; with draft; }
    
      mapping for zcal_holiday_xxx corresponding
      {
        HolidayId = holiday_id;
        MonthOfHoliday = month_of_holiday;
        DayOfHoliday = day_of_holiday;
      }
    }
    
    define behavior for ZCAL_I_HOLIDAYTXT_XXX alias HolidayText
    persistent table zcal_holitxt_xxx
    draft table zcal_d_holit_xxx
    etag dependent by _Public_Holiday
    lock dependent by _Public_Holiday
    {
      update;
      delete;
      field ( readonly : update ) HolidayId;
      field ( readonly : update ) Language;
    
      association _Public_Holiday { with draft; }
    
      mapping for zcal_holitxt_xxx corresponding
      {
        Language = spras;
        HolidayId = holiday_id;
        HolidayDescription = fcal_description;
      }
    }
    
  2. Save and activate.

  3. Open behavior definition ZCAL_C_HOLIDAY_XXX. Add use etag for both entities.

    projection implementation in class zbp_cal_c_holiday_xxx unique;
    use draft;
    
    define behavior for ZCAL_C_HOLIDAY_XXX alias HolidayRoot
    use etag
    {
      use create(augment);
      use update(augment);
      use delete;
    
      use association _HolidayTxt { create; with draft; }
    
      field ( modify ) HolidayDescription;
    }
    
    define behavior for ZCAL_C_HOLIDAYTXT_XXX alias HolidayText
    use etag
    {
      use update;
      use delete;
    
      use association _Public_Holiday { with draft; }
    }
    
  4. Save and activate.

Log on to answer question
Step 2: Test yourself
Where do you define the ETag?
×

Next Steps

Back to top