cancel
Showing results for 
Search instead for 
Did you mean: 

How to apply Filter Query parameters to XS OData Service?

sitara_kola
Participant
0 Kudos

Hi All,

I have HANA tables exposed as XS OData service and I am trying to consume the service in my Fiori application running on SAP Cloud platform.I have created destination for the XS OData service and I am able to see data.

Now I wanted to restrict the data using Query String parameters.

I would like to know how to use $filter query parameter syntax for XS OData service.

We are using the below sample query to test my OData service on Postman and I am getting the following error.

/EMPLOYEESAMPLE.xsodata/EMPLOYEE_ODATA/?$format=json&$filter=LOCATION eq 'ABC'

*********** Error Details***********

{ "error": { "code": "", "message": { "lang": "en-US", "value": "Operator 'eq' incompatible with operand types 'Edm.Int32' and 'Edm.String'." } } }

Do we need to enable Query parameters on HANA Tables like we do implement for Gateway OData services?

Thank you in advance.

Best Regards

Mahalakshmi

pfefferf
Active Contributor

What type has the location property?

As the message says it should be an Edm.Int32 which cannot be compared to a Edm.String which you pass.

Regards,
Florian

sitara_kola
Participant
0 Kudos

Hi Florian,

Location has the following Type generated on Metadata file as EDM.INt32, however on HANA side SQL Data type is NVARCHAR and column store data type is String.

<Property Name="LOCATION" Type="Edm.Int32"/>

BR

Mahalakshmi

sitara_kola
Participant
0 Kudos

Thanks Florian, I modified my query to integer type without single quotes and I could see dataset returned,

for example, I tried with /EMPLOYEESAMPLE.xsodata/EMPLOYEE_ODATA/?$format=json&$filter=LOCATION eq 100

This issue is resolved.

Best Regards

Mahalakshmi

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member365727
Active Contributor
0 Kudos

$filter should work automatically for XSOData services...no code change required.

Checkout the standard documentation for Defining OData service using XSOData

missing error screenshot..