OData service document represents a service which includes entity sets, uniform resource identifier (URI)
It can be opened through the browser with the URI / URL
For example, let us consider the following OData service.
http://services.odata.org/v3/OData/OData.svc/
If you open this URL in browser, it shows up the different entity sets.
As you can see in the above image, the entitysets in this OData service are Products, Productdetails, Categories, Suppliers, Persons, PersonDetails, Advertisements. So it includes totally seven entitysets. The entityset ‘Category’ includes information about all categories.
If the categories is added to the above URL like
http://services.odata.org/v3/OData/OData.svc/Categories
The above url in the browser would list down all the categories.
Similarly if you wish to see all the Products. Then follow this link
http://services.odata.org/v3/OData/OData.svc/Products
URL is case sensitive. So the first letter ‘P’ in Products must be written in Capital. Otherwise it does not work.
It is much similar to the Transaction SE11 (ABAP Dictionary) where we give the Table name. The Data contents can be displayed for this table.
The URLs mentioned above executes the HTTP-Get methods, which in turn calls the Read-OData method. In the background, the data would be retrieved and the result is sent back.
Let us look into an example of retrieving data records with single primary key.
Specific line of record can also be retrieved by specifying the primary key value in the URL.
http://services.odata.org/v3/OData/OData.svc/Products(5)
In the above URL, the products with the ID 5 will be retrieved.
Retrieving data records with two primary keys.
/Entityset( p_key1 = ‘Value1’, p_key2 = ‘Value2’ )
In the above case, both the primary key fields are of datatype string. So the value is mentioned in quotes. If the datatype is integer, then quotes should not be used.
Retrieving data records with WHERE clause.
All the products with a particular category ID can also be retrieved. To achieve this, it must be predefined in the services. We can also navigate from one entity set to another. For example, in the below URL, only the data from the product entity set are displayed.
https://services.OData.org/v3/OData/OData.svc/Categories(5)/Products
Retrieving data records from two different entity sets
This option is much like the JOIN query in SQL. The data from two different entity sets are displayed with a WHERE condition.
https://services.OData.org/v3/OData/OData.svc/Categories(2)?$expand=Products