cancel
Showing results for 
Search instead for 
Did you mean: 

Nested Filter in Expand (OdataV4 feature)

bartdesmet
Explorer
0 Kudos

Nested Filter in Expand

OData V4 supports nested filters in $expand. The request below return People with Firstname "Bart" and all their trips with Name "Trip in US".

GET serviceRoot/People?$filter=Firstname eq 'bart'&$expand=Trips($filter=Name eq 'Trip in US')

Working example from publicly available OData v4 endpoint here (http://services.odata.org/V4/OData/OData.svc/):

http://services.odata.org/V4/TripPinService/People?$filter=LastName%20eq%20%27Calabrese%27&$expand=F...)

how can I get the same result with current SAP Gateway?

Accepted Solutions (0)

Answers (1)

Answers (1)

yevgen_trukhin
Advisor
Advisor
0 Kudos

Hi Bart, current NW GW supports OData v2; therefore, you won't be able to get this feature. However, to get similar result, you could filter in UI on resultset after doing GET with expand, for example, using array methods in javascript (if you use html5 ui).

Best Regards, Yevgen

bartdesmet
Explorer
0 Kudos

Thank you Yevgen for your reply.

I provide the data service through SAP Gateway. I don't build the front-end UI, so I am looking for a solution in the SAP back-end to return the filtered data.
I could suggest a different GET-formulation if that would allow the same data result.

Best regards,

Bart

yevgen_trukhin
Advisor
Advisor
0 Kudos

Bart, i think closest you can do is to do a "function import" that would filter the data the way you need.

Yevgen

bartdesmet
Explorer
0 Kudos

Hi Yevgen,

we don't have any experience with using "function import". We followed explanation provided by sap help and defined a function import via SEGW.

However we are not able to get this called as a nested filter in an $expand. can you give some details on how this should be done?

Best regards,

Bart

yevgen_trukhin
Advisor
Advisor
0 Kudos

Bart, did you read this one: ?

The example there looks:

/sap/opu/odata/sap/ZUSERINFO_SRV/UsersByCountry?Country='US'

Br Yevgen

bartdesmet
Explorer
0 Kudos

Hi Yevgen,

yes we had read that blog post. I followed again all links but I did not get enough information from that to get it up and running. I mean, setting up a function import is ok, but not how to use it as a nested filter in a regular entity set.
In the mean time we solved the request by creating an additional filterable property in the entity set.

that is corresponding to the property of the expanded enitity.

example from my original question is now working as:

GET serviceRoot/People?$filter=Firstname eq 'bart' and NameTrip eq 'Trip in US'&$expand=Trips


We will refactor this once we have our Gateway upgraded tot the level supporting OData V4.

Thanks for your input.

Bart