cancel
Showing results for 
Search instead for 
Did you mean: 

Error when creating Entity from draft in RAP / OData4

Mattias
Active Participant
0 Kudos
Hello,

I'm trying to use a managed RAP to update a custom z-table. I can create the draft, but when I try to create a real active entity I get concurrency errors. I get the same error both when I try to preview my Service Binding and when calling from a "real" fiori elements application.

I'm sure I've missed some detail, but what? I've tried following both blogs and help.sap.com. See details below.

Thanks Mattias

The error in the log is

State of entity CDS~ZI_CAZZ_AWS_PARAMETERS with key EF8959C642E81EDEA69CFEA0135A81FF was already changed (stale If-Match)

I have defined both master etag and local etag in the behaviour definition

define behavior for ZI_CAZZ_AWS_PARAMETERS alias Parameters<br>persistent table zcazz_aws_param


draft table zcazz_aws_paramd
lock master
total etag LocalLastChangedAt
etag master LastChangedAt

{

mapping for zcazz_aws_param

{

CreatedAt = created_at;

CreatedBy = created_by;

LastChangedAt = last_changed_at;

LocalLastChangedAt = local_last_changed_at;

Name = name;

Uuid = uuid;

}

field ( readonly, numbering : managed ) Uuid;

field ( readonly ) CreatedAt, CreatedBy, LastChangedAt, LastChangedBy;

action copyParameter;

create;

update;

delete;

}

and in the data definition

@Semantics.systemDateTime.lastChangedAt: true  
last_changed_at as LastChangedAt,

@Semantics.systemDateTime.localInstanceLastChangedAt: true     
local_last_changed_at as LocalLastChangedAt

The Fields are of the type Timestmp

last_changed_at       : timestampl;
local_last_changed_at : timestampl;
View Entire Topic
JessieCheah
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Mattias,

try and switch your total etag and etag master fields in your BDEF.

total etag LastChangedAt
etag master LocalLastChangedAt

Perhaps this link can explain more? https://help.sap.com/docs/abap-cloud/abap-rap/total-etag

Regards,
Jessie

Mattias
Active Participant
0 Kudos

Hello Jessie,

Thank you for your answer. I did that, and also added the fields LocalLastChangedBy to my db table. But the result is the same

define behavior for ZI_CAZZ_AWS_PARAMETERS alias Parameters

persistent table zcazz_aws_param
draft table zcazz_aws_paramd
etag master LocalLastChangedAt
lock master total etag LastChangedAt

I tried generating a similar app, with the same DB Structure in ABAP Cloud, and there it works. I'm not sure if theversion makes any difference, we're on S/4 2020.