Scroll Top

SAP OData Explained

IBPM Low-code RPAAnthony Cecchini is the President and CTO of Information Technology Partners (ITP), an ERP technology consulting company headquartered now in Virginia, with offices in Herndon.  ITP offers comprehensive planning, resource allocation, implementation, upgrade, and training assistance to companies. Anthony has over 20 years of experience in SAP business process analysis and SAP systems integration. ITP is a Silver Partner with SAP, as well as an Appian, Pegasystems, and UIPath Low-code and RPA Value Added Service Partner. You can reach him at [email protected].

 

If you plan to expose your SAP Data (Table or Query Data) to external environment like UI5/Fiori or HANA, then you need to push your data in a form of API. By API we mean, using OData. OData will generate a service link that can be accessed via internet and can be used to perform CRUD operations. SAP OData in SAP ABAP environment is just like another ABAP Class. We can access the methods of this class using SEGW transaction. We can write our required code here for the data manipulation and once we activate the class, the service link that we generate will act accordingly.

The world is awash with vast amounts of data, and more is being created daily. The main issue is how clients will access this data on their mobile apps, web browsers, and business intelligence tools. Every data source will define its approach to exposing data. Though the different approaches might work, it means that each client would need a unique code to access data from its source, and data creators would need to detail the specific approaches for exposing their data.

SAP Open Data Protocol (OData) is a means of sharing data. It is a protocol and an abstract data model that allows clients to access information exposed by all data sources.

Definition of odata

SAP OData is a standard Web protocol used for querying and updating data present in SAP using ABAP, applying and building on Web technologies such as HTTP to provide access to information from a variety of external applications, platforms and devices.

In SAP, we use SEGW transaction code to create an OData Service. SEGW stands for Service Gateway.

OData Architecture

Parts of OData Architecture

Below are the four main elements that constitute the OData architecture.

  • The OData model: Represents the data fed from different sources in a single format using EDM {Entity Data Model}.
  • The OData Service: Is a service layer on the OData Model. It exposes the endpoint allowing a client access to data using the Odata Client Library and OData Protocol. It also converts data source formats like tables into standard formats that clients can use.
  • OData Protocol: It helps clients get responses and make requests from the OData Service. It is a series of RESTful interactions that transfers data in the forms of JSON or XML.
  • OData Client Libraries that client applications use to access data via OData Protocol. They provide ready libraries that ease the making of OData requests and accessing results, something that will simplify the work of application developers. Some of the OData Client Libraries that provide data access include Miscrosft.NET Framework 3.51. JavaScript and Java.

In terms of SAP, OData is an open standard interface that all software, devices, programs, and applications from the non-SAP world can use to connect with SAP solutions. Through HTTP, users of OData can manipulate an XML document. This means you can construct, modify, write or read the document. Since OData is HTTP-based, all programming languages with HTTP stacks can be used to consume OData services. With OData, web developers can build cross-platform mobile and Web applications. The solution also allows organizations to develop services with high levels of cross-platform interoperability and data integration. This is crucial in the complex sphere that defines modern businesses.

OData has its entire query language directly in the URL. This means when you change the URL, the data sent by an OData feed also changes. As such, you can control the parts of your content that users have access to because you can get back data sent to a consumer.

OData is sometimes called ODBC (Open Database Connectivity) for the web. ODBC is a common API used to access a database management system. To achieve this,  ODBC adds drivers between the database system and application layer to translate a user’s query into a language that databases can understand. In so doing, it becomes the middleware between databases and application layers. Likewise, OData is much like middleware between consumers and producers of data, that’s why people call it the ODBC of the web.

One of the leading products of SAP that rely on OData is the Netweaver Gateway. SAP Netweaver Gateway, also called SAP Gateway, is a technology that allows businesses to connect their devices, environments, and platforms to the SAP solution in which they have invested. With the product, you can access everything you need to help you seamlessly integrate with your SAP system, application, or data.

OData allows data, updates, and queries on SAP Gateway in formats like Atom, JSON, and XML. It also allows a uniform alternative for the structure, query, and display of data. Thanks to this, SAP and non-SAP developers no longer have a communication barrier. You also need no license agreement when using OData services.

Here is a diagram summarizing how SAP Gateway works.

SAP Gateway

With SAP Gateway, you can quickly create apps while better connecting with your customers because the solution frees your SAP data. Moreover, the platform allows you to build apps to support the extension of your SAP infrastructure’s lifespan and increase its flexibility. SAP Gateway works on all platforms and devices. Furthermore, it supports diverse user interaction scenarios.

using the odata service

OData is a REST protocol. The solution uses web technologies like JSON, HTTP, RSS, and AtomPub to give users access to information from various applications. For a REST primer see last month’s blog What is REST?.

REST, as you have already discovered, is a series of architectural constraints rather than a standard or protocol. Developers can implement it in several ways. Nonetheless, the implementation generally follows the same routine. When a client makes a request via RESTful API, a representation of the resource is transferred to the endpoint or requester.

The representation or information is delivered via HTTP in plain text, PHP, Python, HTML, JSON, or XLT. JSON {JavaScript Object Notation} is the most commonly used programming language because it is readable by both machines and humans. The parameters and headers of a request are also crucial in the HTTP delivery of a RESTful request. This is because they contain the crucial identifiers on the request’s authorization, caching, cookies, metadata, and more.

In REST API, a transaction is broken down into modules, each addressing particular underlying components. The request uses the HTTP methodologies described in the RFC 2616 protocol. This means GET retrieves a resource, PUT updates or changes the state of a resource, and POST creates the resource while DELETE removes it.Here is an outline of the REST process. These are what as know as the HTTP Verbs. Learn more here, what is CRUD.

So very simply, in the REST architecture, clients send requests to retrieve or modify resources, and servers send responses to these requests. Let’s take a look at the standard ways to make requests and send responses.

OData does more than exposing your content. It also offers its users full CRUD (create, read, update, delete) support using the following HTTP methods:

  • GET – To retrieve the required data from a specific endpoint. This is the most commonly used HTTP method in websites and APIs.
  • POST – Sends data to an API server for the creation or updating of a resource.
  • PUT – which handles the same tasks as POST. The difference between these two methods is that the requests in PUT are idempotent, meaning you will get similar results when you key in the method multiple times. On the other hand, calling POST repeatedly creates the same resource many times.
  • DELETE – Removes a resource from its specified URL. As one of the frequently used methods in OData, it is prudent to understand how DELETE works.

what are the advantages of using OData

  • It allows you to get human-readable results, meaning you can use virtually all browsers to obtain output data.
  • It is relatively fast and easy to access data using OData.
  • It allows the use of typical web protocols including GET, DELETE, POST, and PUT to access data.
  • It uses stateless applications. This means that a user’s browser will not save any client data. It treats all data requests as a new call.
  • OData receives data in related information pieces such that one piece leads to another. Based on this pattern, not every data piece will be loaded together. Users analyze data to reach its required information when navigating. In so doing, data loads correctly and fast.
  • The messages in OData are self-describing. As such, all non-SAP web developers can understand their content even when they don’t know how SAP or ABAP works.
  • You can implement OData using JSON or XML. These are popular plain text protocols used for the transmission of data online.
  • It allows you to expose your data to users in virtually all locations on all devices. This is crucial with clients now heavily relying on digital information

Versions of OData

Versioning enables the services and clients in SAP OData to evolve independently. Though there are versions 1.0, 2.0. 3.0 and 4.0, the most popular are 2.0 and the latest, 4.0. Version 2.0 includes some add-ons to OData version 1.0. Some of these add-ons are the batching of all requests, automatic message handling, client-side filtering, and caching of data. Version 3.0 and 2.0 are quite similar.

Version 4.0 is the latest upgrade for OData services. Unlike version 2.0, which is a Microsoft OSP {Open Specification Promise}, 4.0 is approved by ISO and OASIS. Moreover, Version 4.0 has more flexible search capabilities than 2.0. In general, Version 4.0 has significant performance improvements than 2.0. With Version 4.0, you get all the necessary tools for uncovering the full potential of your SAP backend. With it, applications can fully handle the sizing, archetype, and complexities that your underlying business model requires.

Summary

So let’s look at what we have learned…

By exposing SAP Business Suite functionality as REST-based OData (Open Data Protocol) services, SAP Gateway enables SAP applications to share data with a wide range of devices, technologies, and platforms in a way that is easy to understand and consume.

Using REST services provides the following advantages:

  • Obtain human readable results; you can use your browser to see what data you will get.

  • Use stateless applications

  • Receive related pieces of information, one leading to another.

  • Use standard GET, PUT, POST, DELETE, and QUERY. If you know where to GET data, you know where to PUT it, and you can use the same format.

Here are some links to get you started on your OData journey!

SAP Gateway and OData

SAP Gateway Foundation for OData V4 Developer Guide

ITP logo

If you enjoyed this blog, SAP OData Explained, please fill out the form below to sign up for our newsletter. We deliver SAP Technical tips & tricks, SAP news, and the current month’s BLOG right to your inbox!

Related Posts

Related Posts

Pin It on Pinterest

Share This

If you enjoyed this post, why not share it with your friends!