cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

RAP App with Read-only root entity

brunobrito2
Explorer
0 Kudos
1,898

Hi,

I had a requirement with 2 custom tables (Parent-Child). I did it fine and it worked... but now they asked to add a new layer to it (G.Parent-Parent-Child)

but here's the trick.... G.Parent is a standard table that we can't touch; It's read-only, and it's only purpose is to make a tie to the previous Parent entity.

Now... they still want to keep the CRUD on Parent and Child... I just need to now allow it on the G.Parent.

I built a custom CDS for the G.Parent, just reading it from the standard and to give it a proper Composition.

 

My problem is how to make the Behavior activate as it does not let me use draft; and remove CRUD from the G.Parent, and considering the G.Parent is in the end a standard table, it does not contain those admin fields:

local_created_by : abp_creation_user;

local_creation_at : abp_creation_tstmpl;

local_last_changed_by : abp_locinst_lastchange_user;

local_last_changed : abp_locinst_lastchange_tstmpl;

last_changed : abp_lastchange_tstmpl;

 

My behavior is like that right now

 

managed implementation in class ZBP_R_COMPANY unique;

strict ( 1 );

with draft;

define behavior for ZR_COMPANY alias Company

persistent table t880

lock master

authorization master ( instance )

//etag master <field_name>

{

// create;

// update;

// delete;

field ( readonly ) Company;

association _Parent { create; with draft; }

 

draft action Activate optimized;

draft action Discard;

draft action Edit;

draft action Resume;

draft determine action Prepare;

}

 

define behavior for ZR_PARENT alias Parent

persistent table ZPARENT

lock dependent by _Company

authorization dependent by _Company

//etag master <field_name>

{

update;

delete;

field ( readonly ) Uuid;

association _Company;

association _Child { create; }

}

 

define behavior for ZR_Child alias Child

persistent table ZCHILD

//lock dependent by <no_to_master_association found>

//authorization dependent by <no_to_master_association found>

//etag master <field_name>

{

update;

delete;

field ( readonly ) Uuid;

association _Parent;

}

 

Is there a way I can pull this off?

Accepted Solutions (1)

Accepted Solutions (1)

MioYasutake
SAP Champion
SAP Champion
0 Kudos

@brunobrito2 

How about using Unmanaged Save? With this, you don't have to specify persistent tables and can implement your own logic for saving data. I've used Unmanage Save for implementing actions on entities based on  standard CDS views. 

 

 

Answers (0)