cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple tables Insert with Primary-foreign key relation in single post

0 Kudos

Hi Experts,

We have a HANA database which has 2 tables with foreign key relationship between them (Like header and Item).
In another HANA XSA system we are developing an application using Cloud Application Programming model and using the same HANA database as a tenant database. In our cds file we are adding these two tables as entities with '@cds.persistence.exists'
In normal scenario we use association or composition in 2 tables and do multi table insert using deep insert.
but since these two tables does not have association/composition relation, is it possible to achieve deep insert. If yes, could you please guide us.


Thanks & Regards,
Soundarya

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Hi Soundarya, I have completed something similar to this requirement in the ABAP Cloud Environment using composition (a form of association). I have not yet tried this for CAP, however it looks the same or similar in concept. Is there something that prevents you from using this pattern https://cap.cloud.sap/docs/cds/cdl#compositions, https://cap.cloud.sap/docs/cds/cdl#associations in your requirement

Then when the OData is generated you can:

POST /EntitySet 
{
  prop:val,
  prop:val,
  prop:val,
  // create by composition or association (deep)
  to_RelatedSet: {
    prop:val,
    prop:val,
    etc...
  }
}

In order for this to work, this relationship would have to be maintained properly and the values of the entityset and relationship would be derived from the OData Metadata.

0 Kudos

Hi ,

In ABAP we create entities then create association between them. Then we perform insert operation through navigation property. I can perform the same insert operation in cds by creating association/composition.


But my issue is both these tables are created in a different HANA database and and during the creation association is not maintained. I am including both these tables in a cds file which is in different XSA system with @cds.persistence.exists.

With @cds.persistence.exists and without association maintained in HANA tenant database how to use expand syntax in cds(in different HDI container) for crud operation. If I don't include @cds.persistence.exists new physical tables in the container which I do not need.

Thanks Soundarya