Open Data Protocol (OData)
Definition of OData can be found in below link:
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 eq ‘2.3M’
In oData the url converts the spaces and special characters to a hexadecimal code something like below:
|Special characters||Code to be used in oData url|
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 Characters||Hexadecimal Value|
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:
There is an SAP note 1671893 which would be useful for the use of filter.
Comments are welcome if this is useful.