Setting Up OData Connection

Objective

After completing this lesson, you will be able to set up OData Connections.

The Inbound OData Service Connection Setup

In this lesson, we cover the setup of an inbound OData service connection. Understanding OData and its application is crucial for creating seamless integrations between different systems.

SAP BTP destination configuration for an OData service, with an arrow pointing to the resulting JSON response showing a list of airlines.

What Is OData?

OData (Open Data Protocol) is a standardized protocol for building and consuming RESTful APIs. It allows for the creation and consumption of queries and updates for various data sources through a standard set of operations.​

Steps to Set Up an OData Service Connection

Let’s walk through the steps to set up an OData service connection using SAP Business Technology Platform (BTP).​

Access SAP BTP Subaccount​

Navigate to your SAP BTP subaccount where you manage your environment.​

Create Destination

Destination Type: Choose OData service.​

URL: Input the URL of the OData service. For example, https://services.data.org.​

Proxy Type: Select Internet.​

Authentication: For services that do not require authentication (like services.data.org, which is open and free), set No Authentication. However, most real-world connections to partners or other cloud systems require some form of authentication, such as OAuth, Basic Authentication, or API Key.​

Save and Test the Connection​

Save your connection setup and test it to ensure it is correctly configured and reachable.​

Practical Insight: A Business Example​

Imagine you are working for a logistics company that must integrate shipment tracking data from a third-party provider.​

Integration: Use OData to connect to the shipment provider's API, retrieve shipment statuses, and update your internal tracking system.​

Secure Access: Implement OAuth authentication to ensure secure access to the third-party data.​

Test the Connection

Building upon the initial setup of an OData service connection, this lesson guides you through the final steps to ensure that your connection is properly tested and integrated into your Universal Model.

A composite image showing a successful SAP BTP destination connection check and the subsequent configuration of an OData service connection using that destination.

Perform Connection Check

Use the Check Connection feature, often symbolized by an icon—such as the snowflake—in the interface.​

This test confirms if the parameters you’ve configured are correct and if the connection to the OData service can be established successfully.​

Integrating OData Connection into Universal Model​

After validating the connection, the next step is to integrate it into your Universal Model.​

Navigate to your Universal Model configuration section.​

Create a new connection and select OData as the connection type.​

Configure the Service Path

Input the service path obtained from your OData service setup. This service path directs to the specific dataset within the OData service that you want to connect to.​

Example: If integrating airline data, your service path might look something like this: https://services.data.org/airlines.​

Filter and Key Field Configuration​

Filter Data: Apply a filter to focus on specific subsets of the data. For instance, you might filter the dataset to only include records related to a particular airline.​

Default Key Field: Set a key field to uniquely identify records within the dataset. This key field ensures that each record can be individually accessed and managed.​

Example: Use a UUID (Universal Unique Identifier) as a default key field for uniquely identifying each record.

The Reader Function Overview

After establishing an OData connection, the next crucial step is to retrieve the data from this connection using the Reader function. The Reader function enables you to read data directly from your model entity, applied by the OData connection.

A composite image showing the configuration of a 'READODATA' function in SAP, detailing the field mapping and general information tabs before saving.

Overview of the Reader Function

The Reader function is a vital feature that allows you to extract data from your model entity. By configuring this function, you can seamlessly query and retrieve the data from your established OData connection.

Steps to Configure the Reader Function

Let’s walk through the process of setting up and using the Reader function to read data from your OData connection:​

Fill in the Basic Fields​

Environment Name: Specify the name of the environment that you are working within.​

Function Name: Assign a meaningful name to your Reader function to help identify its purpose.​

Function Type: Select Reader as the function type.

Configure the Reader Function

Select Reader Type: Click on the Type field and select Reader.​

Specify Connection Name: Input the name of the OData connection you established earlier. This ensures that the Reader function pulls data from the correct source.​

Input Model Entity: Define the model entity that represents the data structure you want to read from. It acts as the source entity for your data.​

Choose Fields to Read​

Select the specific fields within the model entity that you want to retrieve. You can choose multiple fields based on your data requirements.​

Example: If your connection is linked to a customer database, you might choose fields such as CustomerID, CustomerName, E-mail, and OrderHistory.​

Activate Your Environment​

After configuring the Reader function, activate your environment to ensure that all settings are applied correctly.​

Show Data​

Navigate to the Functions screen within your model entity.​

Select your model entity and the configured Reader function.​

Click on Show Data to view the data retrieved from the OData connection.​

Once you pull in the data via Reader function, you will see the three airlines that were selected in ODATA connection. Finaly, data can be displayed in a Reader or Model Entity functions. This was a walk through the ODATA integration steps.

A comparison showing the raw JSON response from an OData service and the corresponding tabular display of the same airline data within an SAP application.

The Outbound OData Connection Configuration

An outbound OData connection enables your system to write data back to an OData service. It is crucial for scenarios where data must be updated or shared bidirectionally between systems.

Diagram of an SAP OData writer setup, showing the configuration screen and the data table of values to be written.

Configuring an Outbound OData Connection

Follow these steps to configure an outbound OData connection and set up the necessary components to write data back to the OData service:​

Choose an OData Service That Supports Writing

Ensure the OData service that you are connecting to accepts data write operations. For example, the airline OData service supports writing data back.​

Create a New Model Entity

Model Entity Creation: Begin by creating a new model entity within your SAP environment. This model entity houses the data that you intend to write back to the OData service.​

Example: If writing back airline data, your model entity might include fields such as FlightID, PassengerName, DepartureTime, and Status.​

Configure the Writer Function

Fill in Required Information: Set up the Writer function with the necessary details to enable data writing to the OData service.​

Environment Name: Enter the name of the environment that you are working within.​

Function Name: Choose a descriptive name for your Writer function.​

Function Type: Select Writer as the function type.​

Specify OData Connection: Input the name of the outbound OData connection that you have established.​

Input Model Entity: Define the newly created model entity as the data source to be written back.​

Map Fields to Write: Identify and map the fields in your model entity that are to be written back to the OData service.​

Save and Activate the Model Entity

After configuring the Writer function, save your settings and activate the model entity to apply the changes.​

Run the Writer Function​

Navigate to the Functions screen within your model entity.​

Select the Writer function you configured and execute it to write data to the OData service.​

As you can see in the ODATA form we can see the new data inserted.

In our writer, we can only use insert writer we can`t delete or update some data in our ODATA.

A comparison showing data in an SAP table to be inserted into an OData service, and the resulting JSON response with the newly added airline records.