Create OData Services using the SAP Gateway Builder
This article shows how to use the SAP Gateway Builder to create OData services that provide ODP based data for the Xtract ODP (OData) component of Xtract for Alteryx.
Note
This article focuses on SAP on-premise systems. For information on how to create OData services in the SAP cloud, refer to SAP Help: Setting up Communication Management.
Prerequisites
- SAP NetWeaver Gateway Release 2.0 Support Package 4 or above. In SAP S/4HANA, the Gateway is embedded, but needs to be activated.
- SAP user that has access to the SAP Gateway Service Builder.
- To extract data using the BW InfoProvider (ODP context BW), an open hub license is required.
- Optional: to transport services from one SAP system to another, e.g., from a test environment to a production environment, authorization for CTS (Change and Transport System) is required.
Tip
To test services directly in SAP, activate the SAP Gateway Client via transaction /IWFND/GW_CLIENT.
Workflow
The creation of OData services can be divided into the following phases:
graph TD
A(<b>Service Definition Phase</b> <br><hr>Create a project to bundle all artifacts that are needed to develop a service.) --> B(<b>Data Model Definition Phase</b><br><hr> Define the model that the service is based on, e.g., entity types, associations, etc.);
B -->C(<b>Service Implementation Phase</b><br><hr>Implement the operations that are supported by the service.);
C --> D(<b>Service Maintenance Phase</b><br><hr>Register and activate the service in an SAP Gateway system.);
Service Definition
Follow the steps below to create a project that bundles all artifacts that are needed to develop a service:
- Log in to the SAP GUI.
- Go to transaction SEGW. The SAP Gateway Builder opens.
- Click Create Project ().
- Enter a name and description for the OData service.
- In the field Project Type, select Service with SAP Annotations.
- If you want to transport the service to another SAP system, define a transport package. If not, enter $TMP (temporary objects).
- Click Continue () to create the project.
The new project is listed in the main window of the SAP Gateway Builder.
Data Model Definition
Follow the steps below to define the model that the service is based on:
- In the main window of the SAP Gateway Builder, select your project and navigate to the DataModel folder of the project.
- Right-click the DataModel folder and select Redefine > ODP Extraction from the context menu.
The window "Wizard step 1: OData access for Operational Data Provisioning" opens. - In the field ODP Context, select a provider context that can access the SAP data source you want to extract. For more information, see Documentation: Provider Context. The depicted example uses the DataSources/Extractors context.
- In the field ODP Name, select an existing ODP object. The depicted example uses the 0CUSTOMER_ATTR extractor.
-
Click [Add ODP] to add the ODP object to the data model.
Tip
An OData service can access multiple ODP objects.
-
Click Next to continue on to step 2 of the Wizard.
- Fill out any missing information and click Next. The window "Create Object Directory Entry" opens.
- If you want to transport the service to another SAP system, define a transport package. If not, click Save () to continue on to step 3 of the Wizard.
-
Use the file tree menu to select the entities and artifacts you want to add to the service.
Note
- EntityOf defines the structure of your data. Select the fields you want to add to the service.
- DeltaLinksOfEntity contains delta links that are required to retrieve only changes (new, updated, or deleted records) to the dataset instead of fetching the entire dataset. Select all items to activate delta updates.
- SubscribedToEntity checks whether a client is subscribed to tracking delta changes. Select this artifact to activate delta updates.
- TerminateDeltasForEntity allows the client to stop tracking delta changes. Select this artifact to clean up unnecessary delta subscriptions.
- entityOf defines the relationship between entities in the OData services, e.g., it links the main entity (EntityOf) with its delta-tracking entity (DeltaLinksOfEntity).
-
Click Finish ().
The subfolders of the DataModel folder now contain the selected entities and artifacts.
Service Implementation
When using the Wizard during the Data Model Definition, the service implementation is auto-generated based on the underlying ODP framework.
The following use cases require manual adjustments:
- Modify how data is retrieved, e.g., to filter or transform the data before returning it to the client.
- Add custom business logic, e.g., to trigger additional actions when data is created/updated.
- Expose custom function imports, e.g., to execute a custom SAP function.
Generate the Service
Before the service can be activated, follow the steps below to generate the runtime objects of the service:
- In the main window of the SAP Gateway Builder, select your project.
- Click Generate Runtime Objects ( ). The window "Model and Service Definition" opens.
- Click Continue (). The window "Create Object Directory Entry" opens.
- If you want to transport the service to another SAP system, define a transport package. If not, click Save ().
The runtime objects for the service are now generated.
Service Maintenance
Follow the steps below to register and activate the service:
- Go to transaction /n/IWFND/MAINT_SERVICE. The "Activate and Maintain Services" menu opens.
- Click Add Service. The menu "Add Selected Services" opens.
- In the field System Alias, select LOCAL.
- Click Get Services to display a list of all services on your SAP system.
-
Select the service you want to register.
Tip
Use Find () to look up the service.
-
Click Add Selected Services. The window "Add Service" opens.
- Check the service information and click Continue (). The window "Add Service" closes.
- Exit the "Add Selected Services" menu and check if the service is now listed in the service catalog.
The service can now be consumed by Xtract for Alteryx's Xtract ODP (OData) component.
Related Links
- SAP Help: SAP Gateway Service Builder
- SAP Learning: Building OData Services with SAP Gateway
- SAP Help: ODP-Based Data Extraction via OData