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

EML: Read All Instances of a BO

selectfrom
Explorer
0 Kudos
1,501

In an ABAP RAP project, I want to read all instances of a BusinessObject via the EML statement "READ ..." like

READ ENTITIES OF zstore IN LOCAL MODE
ENTITY store
ALL FIELDS
WITH CORRESPONDING #( keys )
RESULT result_stores.

but without providing any key, since I want to read all instances.

So, basically, I want to do a query "SELECT * FROM mytable" but as an EML statement for a BusinessObject.

Is that possible, and if so, how?

Accepted Solutions (0)

Answers (1)

Answers (1)

MioYasutake
SAP Champion
SAP Champion

@selectfrom 

How about selecting directly from the underlying CDS view (zstore)?

One note: Draft entities cannot be retrieved using above method; therefore, if draft data is required, you need to retrieve them from the draft table.

selectfrom
Explorer
0 Kudos
Thank you for the answer. This is a work-around that would probably work but not quite what I'm looking for. Wouldn't this circumvent the BO logic by going directly to the data? That doesn't seem like an optimal solution to me
MioYasutake
SAP Champion
SAP Champion
@selectfrom What happens if you pass an empty tale to the "WITH CORRESPONDING #( keys )" statement?
selectfrom
Explorer
0 Kudos

I did this and it gives me no instances as result. Understandable, since no key (there were none) matched any instance:

 

 

DATA empty_table TYPE TABLE FOR READ IMPORT zstore.
READ ENTITIES OF zstore IN LOCAL MODE
ENTITY store
ALL FIELDS WITH CORRESPONDING #( empty_table )
RESULT DATA(result).