Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ODATA GetEntitySet Filter - IT_FILTER_SELECT_OPTIONS doesn't recieve the parameter properly

angeliev
Explorer
0 Kudos
1,901
  • SAP Managed Tags:

Hello guys!

I have searched for a solution on my issue on the forum and the internet but unfortunately couldn't find any.

So I want to build an ODATA Service which reads data from the database for a certain id in a certain period of time.

My input parameters after ?$filter are "Malo" type ext_ui, datetime (gt and lt) and time (gt and lt).

My test query string looks like this:

ProfilwerteSet??$filter=Malo eq '1234' and Datum ge datetime'2020-01-01T00:00:00' and Datum le datetime'2020-01-03T00:00:00' and Zeit ge time'PT08H00M00S' and Zeit le time'PT22H00M00S'


In this case I don' get any of the parameters in the "IT_FILTER_SELECT_OPTIONS" table.


I have tried different types of query strings so that I see which work and which not. So If I use query string for "Malo" "date" and "time" without (gt and lt, bit eq), then I become the parameters in the table =>

/ProfilwerteSet?$filter=Malo eq '1234' and Datum eq datetime'2020-01-01T00:00:00' and Zeit eq time'PT22H00M00S'

/ProfilwerteSet?$filter=Malo eq '1234' and Datum eq datetime'2020-01-01T00:00:00' and Zeit eq time'PT22H00M00S' and Profil eq 'AB1234'

So using multiple parameters that are "eq" is allowed, but using 2 ranged parameters like in my example:

ProfilwerteSet??$filter=Malo eq '1234' and Datum ge datetime'2020-01-01T00:00:00' and Datum le datetime'2020-01-03T00:00:00' and Zeit ge time'PT08H00M00S' and Zeit le time'PT22H00M00S'

is not ?

Thank you in advance for your answers guys, that would help me a lot!

Best wishes,
Angeliya

1 ACCEPTED SOLUTION

bernhard_grusie
Product and Topic Expert
Product and Topic Expert
1,813
  • SAP Managed Tags:

Hi Angeliya,

the OData $filter expression is very powerful. ABAP select options have limitations, e.g., see 2305033 - SAP Gateway OData V4 $flter Consulting Note

"

The ABAP select options have the following constraints:

All properties within an 'orExpr' must have the same name.

Valid: "name eq 'Jonathan' or name eq 'Hugo'"

Invalid: "name eq 'Jonathan' or age eq 20"

All properties within an 'andExpr' (including nested orExpr) must have a unique name.

Valid: "name eq 'Jonathan' and age eq 30"

Invalid: "name eq 'Jonathan' and name eq 'Peter'"

Select options cannot be used for null-values. "

If your $filter expression becomes too complex, you won't be able to use the select options. Alternatives:

1. Another feature is to create an Open SQL where clause from the $filter expression.

2. The $filter tree. This is the full $filter in a tree format. Using this is complex.

If you were using RAP, $filter would work out of the box.

Best regards

Bernhard

2 REPLIES 2

bernhard_grusie
Product and Topic Expert
Product and Topic Expert
1,814
  • SAP Managed Tags:

Hi Angeliya,

the OData $filter expression is very powerful. ABAP select options have limitations, e.g., see 2305033 - SAP Gateway OData V4 $flter Consulting Note

"

The ABAP select options have the following constraints:

All properties within an 'orExpr' must have the same name.

Valid: "name eq 'Jonathan' or name eq 'Hugo'"

Invalid: "name eq 'Jonathan' or age eq 20"

All properties within an 'andExpr' (including nested orExpr) must have a unique name.

Valid: "name eq 'Jonathan' and age eq 30"

Invalid: "name eq 'Jonathan' and name eq 'Peter'"

Select options cannot be used for null-values. "

If your $filter expression becomes too complex, you won't be able to use the select options. Alternatives:

1. Another feature is to create an Open SQL where clause from the $filter expression.

2. The $filter tree. This is the full $filter in a tree format. Using this is complex.

If you were using RAP, $filter would work out of the box.

Best regards

Bernhard

angeliev
Explorer
0 Kudos
1,813
  • SAP Managed Tags:

Hi Bernhard,

thank you very much for your fast and accurate response!

I had to customize the query a bit and put the "date" and "time" in brackets because of this:

=>

/ProfilwerteSet?$filter=Malo eq '1234' and (Datum ge datetime'2020-01-01T00:00:00' and Datum le datetime'2020-01-03T00:00:00') and (Zeit ge time'PT08H00M00S' and Zeit le time'PT22H00M00S')

Anyways, very useful information, thank you very much! 🙂

Have a great day.

Best wishes
Angeliya