Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
Product and Topic Expert
Product and Topic Expert
Previous   Home   Next

Open Data Protocol (OData) (see also [MS-ODATA]: Open Data Protocol (OData) is a data access protocol for web applications. A JavaScript library such as datajs is used to access an OData source.

The below sample uses an OData source from There is a list of sample services available at

Note: the Kapsel SDK as of SP 14, supports the V2 version of OData.

One of the nice features of OData is how simple it is to access an OData source. Simply enter the OData URL with a $metadata parameter to see a description of the service.$metadata.

It is also possible to use a free online tool such as xodata to visualize the metadata.

This describes that there are three entities named Products, Categories, Suppliers, what fields are in each entity and the associations between them.

To access the data, specify which data to read such as As seen below, there are three categories, Food, Beverages and Electronics.

The data is formatted as either atom(xml) or json. The json format is less verbose which means the data exchanged takes less bandwidth.$format=json

The URLs to navigate the association between categories and products are shown in this link$format=json which shows the products for category 2 or Electronics.

Here are a few more examples.
First three products$top=3&$format=json
Fourth product$format=json
Products that start with the letter F$filter=startswith(Name, 'F') eq true&$format=json

The following links may also be helpful.
URI Conventions
Basic Tutorial

The steps below demonstrate how to create a simple OData web app.

  • Create a folder named C:\ODataSample.

  • Download the latest datajs file (datajs-1.1.2.min.js) from datajs and place it in the folder ODataSample.The datajs JavaScript library provides a read method that takes an OData URL and returns the data as a JavaScript object.

  • Create a file named ODataSample\products.html and paste in the following code.
    <script src="datajs-1.1.2.min.js"></script>

    function successCallback(data, response) {
    var productsTable = document.getElementById("productsTable");
    for (var i = 0; i < data.results.length; i++) {
    var row = productsTable.insertRow(1);
    var cell1 = row.insertCell(0);
    var cell2 = row.insertCell(1);
    var cell3 = row.insertCell(2);
    cell1.innerHTML = data.results[i].Name;
    cell2.innerHTML = data.results[i].Description;
    cell3.innerHTML = data.results[i].Price;

    function errorCallback(e) {
    alert("An error occurred" + JSON.stringify(e));

    function init() {
    OData.defaultHttpClient.enableJsonpCallback=true; //"", successCallback, errorCallback);

    <body onload="init()">
    <table id="productsTable"><tr><th>Name</th><th>Description</th><th>Price</th></tr></table>

  • Try it out by opening the file in Chrome.

Previous   Home   Next