Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member196601
Active Participant

Open Data Protocol (OData)

Definition of OData can be found in below link:

Open Data Protocol - Wikipedia, the free encyclopedia

I would like to share some tips in ODATA usage like when we use a filter to get data or when we use key predicates of the oData url there are some important points that needs to be considered.

To pass date field to oData url the below syntax needs to be followed:

https://<system>:<host>/<path>/<service>/<entityset>?$filter=Cdate eq datetime'2014-11-21T00:00:00'

Currency fields / decimal fields can be used as below:

https://<system>:<host>/<path>/<service>/<entityset>?$filter=Price%20eq%20%272.3M%27

https://<system>:<host>/<path>/<service>/<entityset>?$filter=Price eq '2.3M'

In oData the url converts the spaces and special characters to a hexadecimal code something like below:

Special charactersCode to be used in oData url
'%27
space%20

When using special characters like /, +, etc you can't use them directly instead you need to use it with the alternate hexadecimal code for the special character like shown below:

Special CharactersHexadecimal Value
+%2b
/%2f
?%3f
%%25
#%23
&%26

And when we use a date field with "less than" and "greater than" condition as well as another field with "and" condition in the oData url, then in the method GET_ENTITYSET we generally don't get the filter select option filled and for that to be filled in proper way we will have to do the below trick:

https://<system>:<host>/<path>/<service>/<entityset>?$filter=Matnr eq '12342' and (Cdate le datetime'2014-11-21T00:00:00' and Cdate ge datetime'2014-11-20T00:00:00')


Below urls are very informative for oData:

http://www.odata.org/documentation/odata-version-3-0/url-conventions/

http://msdn.microsoft.com/en-us/library/hh166950(v=nav.71).aspx

There is an SAP note 1671893 which would be useful for the use of filter.

Comments are welcome if this is useful.

Labels in this area