cancel
Showing results for 
Search instead for 
Did you mean: 

Is it necessary to have filter fields in the entity type?

former_member227510
Participant
0 Kudos

Hi,

I have an entity type.... with the following fields

Employee ID

Employee Name

In the url, I want to pass along with the entity set name two other filter parameters

For eg.

http://nwfront.abc.net:2020/sap/opu/odata/sap/ZMY_SRV/allRulesSet?$filter=DepartmentID eq '1' and DepartmentName eq 'Testing'

Based on these filters, I want to get all the employees id and names in the get_entityset method in the export parameter et_entityset

Is it possible?

I don't want to include the Department ID and Department Name fields in the entity type as my model will have duplicates ( same values repeated) for these fields all over and unwanted columns.

Thanks and Regards,

Gopa

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member190010
Contributor
0 Kudos

Hi Gopak,

If you want to add the possibility to filter to the odata web service, you have to add some code i nthe odata web service.

There is an excellent detailed blog on how to do this:

Regards,

Emanuel

former_member227510
Participant
0 Kudos

Hi Emanuel,

Thank you for the solution.

I went through the document. It is quite informative with respect to filtering and paging.

However, my requirement is I want only two columns ( fields ) that should go as part of my et_entityset output.

And my entity type should only contain the two column fields

Employee ID

Employee Name

And I should be able to pass Department ID and Department name as filters.

But when I tried yesterday, the filtering won't happen as Department ID and Department name fields are not part of the entity type along with Employee Id and Employee Name.

So even if I give all the four fields as part of my entity type, can I anyhow delete the other or disallow the other two repeating fields from the final et_entityset.

I know that columns from an internal table cannot be deleted either. But that doesn't make sense too.

Thanks and Regards,

Gopa

former_member185414
Active Contributor
0 Kudos

Hi,

If you are hardbound  on your requirement of not having additional fields on the entityset (which does not make much sense to me), then you can create a function import which will have filters as input parameters (Department Id and Department name-again a filter on name is never advised and it should be only on id) and exporting would be the same entity which has two fields - Employee Id and Name.

It should serve your purpose.

BR.

former_member190010
Contributor
0 Kudos

Hi Gopak,

In that case, you should use a Function Import.

Check the following post:

Regards,

Emanuel

former_member190010
Contributor
0 Kudos

Were you able to solve the issue?

junwu
Active Contributor
0 Kudos

how difficult for you to try in the system?