10/1/2020 by Ronak Hingorani Posted in SAP

Learn ODataIntroduction

OData stands for Open Data protocol, originally developed by Microsoft and shared through the open speciï¬Âcation. SAP is one of the early adopters of the this protocol and the latest available version is 4.0.

It is essential to understand that OData is not only related to SAP; it is an open data protocol, and there are a variety of frameworks and languages (ABAP, JAVA, Node.js, Python) that can be used to build an OData.

OData helps applications concentrate on business logic without being concerned about the various API approaches to define request and response headers, status codes, HTTP methods, URL conventions, media types, payload formats, query options, etc.

 

OData in a nutshell

Before understanding the concept in detail, some components should be understood as prerequisites like HTTP/HTTPS and REST. In a client-server architecture, communication protocols like HTTP (Hypertext Transfer Protocol) and HTTPS (Hypertext Transfer Protocol Secured) are used transports messages over a network between the client (Browser) and the server (Database). 

 

REST (REpresentational State Transfer), also known as Stateless Transfer, defines a set of rules about how HTTP/HTTPS should be used to exchange XML or JSON messages. REST describes ways to GET/PUT/POST/DELETE data from the server using specific commands in the client (browser). One of the ways to implement REST is OData because it defines a set of best practices for building and consuming REST APIs using HTTP/HTTPS for effective communication between the client (browser) and the server. 

 

How to learn OData?

To get started with OData and building your first web service, we highly recommend this training course: Create, Test, Debug & Analyze Your First SAP OData Service. This course introduces the theory and terminology required for understanding the topic, then takes a practical step-by-step learning approach to creating an actual OData project. 

 

Watch this short intro video for the course:

 

This training course provides a comprehensive step-by-step approach to learning OData and how it is used with SAP. The training starts with HTTP/HTTPS and moves gradually to building an end-to-end web service with steps on how to consume the same.

It explains the REST architecture and constraints like Uniform Interface, Stateless, Client-Server, Cacheable, Layered System, Code on Demand. With a detailed understanding of HTTP and REST, we start to learn about the basics of OData and how it services are built using simple HTTP to communicate between Client and Server. 

Our OData training course provides in-depth technical insight on the topics below:

SAP Netweaver Gateway

Seamless connection of devices, platforms, and environments to SAP data using the OData services and avoidance of point-to-point solutions with low TCO (Total Cost of Ownership).

SAP Netweaver Gateway Service Builder 

This is SAP GUI-based modeler to create and publish web services using transaction SEGW.

SAP Gateway Components

Before NW 7.4, there were three add-on components, namely GW_CORE, IN_FND, and IW_BEP; with the latest release, all three are bundled into the single Gateway Foundation component SAP_GWFND.

Deployment options

There are two types of deployment approaches available:

  1. Hub Deployment
  2. Embedded Deployment

Both deployment options have their pros and cons. However, deployment options do not affect the way OData works.

Creation of OData Service

This section will help you understand how to create an OData Project in SAP transaction code SEGW, import a DDIC structure, create an Entity, Entity Sets, Associations, and generate runtime objects. Generating runtime objects creates a service, model and its associated classes, called Data Provider Class (DPC) and Model Provider Class (MPC). Methods of these classes are defined for adding business logic.

CRUD Operations

Once the project is created and entity/entity sets are defined, it is time to implement logic to perform actions. Under the project structure, each entity has separate properties, and each entity set has its own CRUD operations under service maintenance. This defines the various activities a service can perform (i.e., Create, Read, Update, Delete).

Register OData Service

Transaction code /N/IWFND/MAINT_SERVICE is used to register a service in SAP. In the case of an embedded deployment, the frontend server and backend ABAP server are on the same system, and the registration is done on the system where the project is created. Alternatively, when using the hub system, they are on a different system, and the registration is done on a separate Front-End System. 

Debug/ Troubleshoot/ Error Handling

Once the service is registered, the SAP Gateway has its own testing tool to help developers test the service. There are various formats in which the output can be seen in the SAP Gateway Client using $format=json or $format=xml.

It is vital to know about the errors that OData services come across and their causes. For Example, error numbers with 1xx are Informational, while error numbers beginning with 2xx are Success messages, 3xx: Redirection, 4xx: Client Error, 5xx: Server Error.

 

Who should learn OData?

The best individual to learn OData, with respect to SAP, would be a developer with some SAP ABAP knowledge who aspires to become a full-stack developer in the future. An ABAP developer already knows SAP development and customization related to SAP. With skills in OData, the developer would be capable of exposing SAP data to the internet using web services. Also, it is a vital part of the upcoming SAP advancements like SAP Cloud Platform and Cloud Foundry. 

Apart from just exposing SAP data to UI5/FIORI, there are other uses of OData, one of which is explained in this training course: Microsoft Excel Integration with SAP Using OData. This course teaches how to perform handshakes with web services to connect to SAP and to download data to MS Excel.

 

How can you achieve your career goals with OData knowledge?

We are all aware that SAP is rapidly moving towards internet-enabled and mobile applications. These web and mobile apps rely on data sent from SAP, and OData, as we now know, is the key to this data transfer. 

Most developers building mobile and web applications often are comfortable with technologies such as .NET, JAVA, HTML5, and CSS, but do not have a strong SAP background. With OData skills, you would be ready to step into any UI5/FIORI project as an OData backend developer initially and help projects use SAP data via web services. This can act as a stepping stone to getting into the UI5/FIORI world and learn this emerging technology. 

Having said that, UI5 apps/FIORI is an entirely new world of UX programming languages, but OData skills will help you grow one step closer towards being a Full Stack Developer.

 


Author Photo

Ronak is an ABAP/UI5/FIORI Consultant with more than 8 years of experience, with a demonstrated history of working in the SAP consulting industry. He has worked across various SAP modules like MM, SD, FICO, P2P and has helped client by developing a scalable technical ABAP solution. Over the past 8 years he has built expertise in server-side ABAP technology and advanced ABAP skills like CDS, AMDP, OData and in client-side UX technology like UI5 Framework (HTML/CSS/ JavaScript) and FIORI. He also has experience in SAP Upgrade from ECC to HANA (1709/1909).
More Blogs by Ronak Hingorani:
full-stack webide
SAP WebIDE Full-Stack Edition Setup and Configuration

Introduction SAP WebIDE is a powerful, extensible, web-based integrated development tool that simplifies end-to-end full-stack application development. SAP WebIDE supports the entire application lifecycle, ...

sap webide
SAP WebIDE Personal Edition Setup and Configuration

Introduction SAP WebIDE is a web-based development tool to build SAPUI5 and FIORI applications. WebIDE is an open source code editor development environment for a single user. There are two kinds of ...

fiori elements
Application Development with FIORI Elements

Introduction SAP Fiori Elements, formerly known as smart templates, has been around since 2015 (when SAP S/4HANA come out) and provides a framework for the most common application patterns.  If ...