Retrieving Data for an OData Service via a Function Module Call from an External SAP System
Retrieving Data for an OData Service via a Function Module Call from an External SAP System
In this post, I’d like to explore a simple example of working with an OData service, which, upon execution, calls a function module located on an external SAP server.
Problem Statement
Create and configure an OData service that retrieves data from a "neighboring" SAP system by calling a function module hosted in that system.
Some Background
See: SAP Gateway Foundation Configuration Guide
Solution
Initial Setup
For this demonstration, I’ll be using two systems: NPL and A4H. The service will be developed in the NPL system, while the data to be retrieved (and the associated function module) resides in the A4H system.
Let’s get started!
Step 1: Configure RFC Connections Between NPL and A4H
Using transaction SM59, set up RFC connections in both systems. The connections must be configured to correctly identify the target servers specified within them.

Step 2: Verify the Presence of the Function Module (A4H)
Ensure that a function module is active in A4H and is enabled for remote calls via RFC.

As shown in the screenshot, the source code of this FM is quite straightforward. It reads data from a custom Z* table and assigns it to an export parameter. The following video demonstrates its output.
Step 3: Create the OData Service (NPL)
The next video shows the steps involved in creating a new OData service. This service includes one entitySet
, whose structure is based on the function module from A4H (see Step 2).
Step 4: Configure System Aliases (NPL)
Navigate to the following SPRO path to configure the system alias:
SAP NetWeaver => Gateway Service Enablement => Backend OData Channel => Connection Settings to SAP Gateway => SAP Gateway Settings

The purpose here is simple: define a system alias for the remote system from which the OData service will pull data. Be careful to match the alias name with the correct RFC destination.
Step 5: Register the OData Service (NPL)
The following video outlines the steps to register the OData service in NPL and associate it with the system alias for A4H.
Step 6: Test the OData Service Functionality (NPL)
Verify that the OData service works in NPL, first demonstrating that the local system has no data table. All data continues to reside in the Z* table of the A4H system.
Step 7: Build a SAPUI5 App and Call the OData Service (NPL)
Test the service by deploying a SAPUI5 application in NPL that invokes the previously created OData service.
Summer passed by all too quickly.
With love,
ignatov