cancel
Showing results for 
Search instead for 
Did you mean: 

oData Service Entity Set Filtering

owen_carnes
Participant

Hello,

I built an oData service in our backend development system, and I implemented the GET_ENTITYSET method, which just selects the whole table.  I am calling the service through a separate SAP Gateway Server.  I would like to be able to filter this data in the URL call.  When I call the service in the browser, I get the entire table of results, which is to be expected.  When I add the filter parameter, I am still getting all of the results, it isn't applying the filter.  Any ideas as to why this is?  More details below:

Entity Set "DriversSet":

Entity Type "Drivers":

GET_ENTITYSET Method:

Request from Gateway Server (no filter, executes successfully, returns as expected):

Request from Gateway Server (added filter, executes successfully, but does not actually filter any data, returns full results again):

Thanks for your help,

Owen

Accepted Solutions (1)

Accepted Solutions (1)

former_member184867
Active Contributor

Gateway Framework does not perform any filter for you.

The implementation has to be done explicitly in the data provider. You need to narrow the result using values available through IT_FILTER_SELECT_OPTIONS in method GET_ENTITYSET.

Logically it is not a good idea to do a default implementation from the Gateway Layer because

you always pull extra data from the DB which is eventually filtered out by Gateway.

Rather than doing it at the framework level , it can be done more efficiently at the place where the data is being selected for example at the SELECT statement or at the BAPI .

You can refer to for some example

EkanshCapgemini
Active Contributor
0 Kudos

And just to add what Atanu has correctly mentioned, I think this confusion is because of the 'Filterable' check-boxes that you have checked. I think that you are in a assumption that if you check these boxes, gateway framework will automatically handle the filters but it is not.

These check-boxes are to well define metadata document and does not handle filtering in service implementation. It is just to define that these are the parameters on which you(developer) has enabled filter.

It is a best practice to well define metadata document as there are some tools(like MS Excel Add-in for gateway) which rely on metadata document to enable/disable certain operations.

Regards,

Ekansh

owen_carnes
Participant
0 Kudos

Thank you both very much.  I hadn't found that article yet, and all the other articles failed to mention the coding on the backend for filtering the oData services, I believe they assumed that portion was already done.  I will go back and implement that part first.

Thanks again,

Owen

Answers (3)

Answers (3)

Hi Owens I was in a similar situation. I implemented this simple code in the get entity set. I was accessing a table and wanted to possibly use alternatively two filters to retrieve data. It worked for me. Hope the code is clear and it helps.

Cheers, Rafael

glauco
Active Contributor
0 Kudos

thank you.

Pavan_Golesar
Active Participant

Hello Owen,

That's too skeptical,Assuming that you are using BAPI mapped for the Read and Query operation.... Can you show us the mapping to data source in service builder.

If I would be you, I would firstly check if BAPI working fine in se37 tcode and running and testing it.

if yes then clear cache and check again from Gateway client for the same.

Generally clearing the cache help and works many times.

Hope this was helpful.

Regs,

PG

JamesZ
Advisor
Advisor
0 Kudos

Question is answered, but hope below could help:

https://blogs.sap.com/2016/05/31/odata-service-development-with-sap-gateway-code-based-service-devel...

Add support for $filter to your code

could also help: