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

Why do we need read entity in RAP ?

das_shubhashish
Explorer
0 Likes
2,121

I am learning RAP, so I have a doubt that why do we need Read Entitiy in RAP . I understood that to read the data from BO. but we already had select stmt/modify/insert stmt for that. I could have written select from cds entity to get my data in an internal table(just assuming).

requesting your help on this. this could be silly question but as i am new it feels a lot to me. tnx in advance

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Sijin_Chandran
Active Contributor
0 Likes

To complete the CRUDQ operations of a REST compliant HTTP Service!

Consider the in the end BO or say the Service you are building which needs to be consumed by an outside Entity( meaning other outside client/consumer like eg. Postman tool), for it to be accessed from an outside world/client it should have options for implementing R READ operations as well. Read based on Navigations, Expand etc. these won't work without that.

Thanks,

Sijin

Sijin_Chandran
Active Contributor

Answers (3)

Answers (3)

junwu
SAP Champion
SAP Champion
0 Likes

it deals with transaction buffer, I believe.

imagine you are creating a record, it is not saved yet, will you get that record via querying cds?probably not, but Read entity will give that record, if I am not wrong.

same for update case, if update is not saved, querying cds will give u old data, read entity will give updated data in your session/transaction.

saurabh__khare38
Participant
0 Likes

Hi Subhashish,

A RAP BO(Business Object) is not just a CDS view. It usually represents a real-world artifact that has both a structure (1 or more CDS views with parent-child hierarchies/associations)  as well as a behaviour(operations and properties). 'Read Entities' which is a part of EML(Entity Manipulation Language) provides type-safe access to the RAP BO while abstracting the complexity of the underlying BO implementation from the developer.

More here:

Business Object

EML

Best Regards,

Saurabh

TuncayKaraca
Active Contributor
0 Likes

Hi @das_shubhashish,

It's a good question! Once we start learning Entity Manipulation Language (EML), it's natural to wonder why we need to use EML, especially READ ENTITY, ENTITIES

The answer is simple. If there is a Business Object (BO) and its data model with CDS View Entities, then use READ ENTITY, ENTITIES in either local mode or external usage. I would strongly advise against using these BO's CDS View Entities directly.

Secondly, you will undoubtedly benefit from using READ ENTITY, ENTITIES in LOCAL MODE. This allows you to read affected entity instances and draft-enabled entity instances, among other advantages.

Furthermore, you can read data from not only the selected entities but also from associated entities either  IN LOCAL MODE and external. In this case, the BO has a root entity with one or more child and leaf entities.

Thanks,
Tuncay