cancel
Showing results for 
Search instead for 
Did you mean: 

How to get entity set with input parameters?

Former Member

Hello gurus!

I know this may be a newbie question, but I've looked around first and found no solution yet.

I need to get table of entities by some criteria. I need the result to be selected by this criteria, not filtered after selection so $filter is not the answer as far as I can see.

I want to get some objects hierarchy. There are lots of objects and a root object ID. So I want to pass that root ID and get all the hierarchy from that ID and not the whole objects set. I've created Z Function Module, it imports the RootID and exports the hierarchy table (table of object entities). But I found no possibility to pass the import param and get the whole table.

If I pass param to URL it fires the GetEntity(Read) and returns only 1 root object. If I pass no params it fires the GetEntitySet(Query) and tries to give me all the objects presented in my system.

Any help's appreciated!

Best regards,

Anton.

Accepted Solutions (1)

Accepted Solutions (1)

kammaje_cis
Active Contributor
0 Kudos

Hi Anton,

Important point here is data modeling. Can you model your entity so that output for a root object is a flat structure? Then READ(passing the root object key) is the solution for you.

The other option is to create an entity to hold a single object.  Create a navigation to the same entity from this. Then use $expand to fetch root object and all the children. You may read about $expand in odata.org.

Regards

Krishna

Former Member
0 Kudos

Hello, Krishna!

Creating a navigation to the same entity is the answer. Now my URL looks like:

/sap/opu/odata/sap/my_service/ObjectEntitySet('key_object_num_here')?$expand=Hierarchy

Hierarchy here is a navigation property in Object entity. That navigation property points on circular association.

The problem is solved, thanks for your help!

Best regards,

Anton.

Answers (1)

Answers (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Anton,


I would like to go with what Krishna said.

You cannot get set of data by implementing Get_Entity so this option is ruled out.

You can get Set of data by implementing Get_EntitySet. But here you have to pass your input parameters only as Filters in-order to fetch data or you just have to get collection of data.

There is no other way apart from this as GW delegates call to Get_EntitySet based on $filter only or based on EntitySet name.

You can create association and navigation to fetch data but here also in order to accomplish your scenario you have to either pass Keys in the Parent Entity or Filters & get the child entries using $expand.

Regards,

Ashwin