cancel
Showing results for 
Search instead for 
Did you mean: 

OData Service for search functionality?

Former Member
0 Kudos

Hi all,

I am new to OData Services in HANA. I want to build OData service for search capability.

Problem :

1. I want to pass search_criteria and some of the filters from my web application to OData Service (Basically REST url).

2. Based on parameters I get from web application to OData Service I want to use these parameters in my service.

3. Plan is from OData service I may call Stored Procedure or View and pass search criteria and filters details to Stored Procedure or View and get the appropriate result which would be the response of my service (most probably JSON response)

Can someone provide some idea how to go about this.

Your help will be greatly appreciated.

Thank you.

Dharmesh

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Have you read up on XSODATA?  It is a development object built into HANA for building OData services and it has all the functionality you described.  You don't have to code the service itself. You create an XSODATA specification file which describes which table(s)/view(s) you want to use as the source of the service.  I would suggest reading more about XSODATA in the HANA Developers' Guide, HANA Academy, or openSAP and see if it meets your needs.

Former Member
0 Kudos

Hi Thomas,

First of all thank you for your reply. I am also taking training that you have on openSAP but haven't completed yet.

Yes, I have created sample OData service using XSODATA and I am referring your videos to do that.

I am also going through Developers Guide but not getting clear idea how can I pass query parameters through URL and how can I consume that in the searchService.xsodata file. Once I am able to do that I also want to pass that parameters to stored procedure so that base on the search criteria I can get result back.

I would really appreciate if you can guide me what kind of mechanism I should use to achieve this and if you have example to refer that would really great.

Regards,

Dharmesh

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Filter and sorting is built into the OData framework and can be supplied automatically to any field exposed in the service. For example you have a service with the Column Currency in it.  You want to filter and receive records with only Euros.  You would add this to the request URL:

$filter=((Currency%20eq%20%27EUR%27))

There is nothing you need to do on the server side to process this.  The filter is handled by the XSODATA framework.

Former Member
0 Kudos

Hi Thomas,

Thank you and I really appreciate you help on this.

That's worked well, couple of additional questions

1. Is it possible to pass JSON as filter request?

2. Is it possible to call Stored Procedure in the service instead of calling Table or View?

Regards,

Dharmesh

sreehari_vpillai
Active Contributor
0 Kudos

Hi Dharmesh,

1. You can not pass JSON objects as filter string in OData . But you can achieve the same in XSJS. Read the below blog.

http://scn.sap.com/community/developer-center/hana/blog/2014/06/23/transferring-complex-structured-d...

2. Stored Procedures can be consumed if you consume the same in a scripted calculation view

Sreehari

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Thomas , Sreehari,

Thank you for your all answers and I found these are really helpful. I learn a lot from these posts.

While going through all this I found something call $search system query option for doing in full-text search which was introduced as part of OData-4.

As far as I know HANA support OData-2 with SP8. Is there a way I can use $search option for my OData Service?

Regards,

- Dharmesh

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

OData ver 4 is on our radar but it won't be in SPS9.

Former Member
0 Kudos

That means I can't use $search option right

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

No but if you want full text search capabilities you should look at the specialized SINA service framework in HANA: