Read SAP S4 / HANA data in SSIS (OData REST API)

Introduction

In our previous post, we saw how to call REST API in SSIS. Now let’s learn how to read data from SAP S4 / HANA OData Service (i.e. S/4HANA). SAP HANA provides an OData REST API interface to access data in your application using HTTP Protocol. We will use the SSIS XML Source component to read SAP data and load it into the SQL Server Table in a few clicks.

 

Prerequisites

Before we perform the steps listed in this article, you will need to make sure the following prerequisites are met:
  1. SSIS designer installed. Sometimes it is referred to as BIDS or SSDT (download it from the Microsoft site).
  2. Basic knowledge of SSIS package development using Microsoft SQL Server Integration Services.
  3. Make sure ZappySys SSIS PowerPack is installed (download it, if you haven't already).
  4. (Optional step). Read this article, if you are planning to deploy packages to a server and schedule their execution later.

About SAP HANA / OData REST API Service

You can expose your SAP Data using ODATA REST API Service. Here is a good article that shows how to expose data as an OData Service. For more information on the SAP OData Service feature check the SAP help page. If you are new to OData standard then read an article to learn more about it. If you need an XML-based OData Service then use the test URLs below:

Now let’s look at how to read SAP Data in SSIS. At this point, we assume you have exposed your data as OData Endpoint.

Step-by-Step Instructions

Let’s look at the step-by-step approach to how to read SAP data using SSIS components. Then we will load SAP HANA data into SQL Server.

Read SAP HANA data using XML Source

First, let’s look at the steps on how to configure XML Source. We will read data from SAP S4 / HANA OData Service and then we will look at how to load data into SQL Server in the next section.

  1. Open an SSIS package.
  2. Drag Data Flow Task from SSIS Toolbox and double-click it to open it.
  3. From the SSIS Toolbox drag ZS XML Source onto the background of Data Flow (in the designer). Double-click it to open the XML Source configuration window.
  4. Change Data Format to OData. Selecting this option will take care of REST API pagination too.
  5. Enter your OData Service URL. Its format looks similar to the one shown below. Replace 3 parts with your own value (i.e. replace {MY-INSTANCE}, {MY-PROJECT}, {MY-TABLE}):
    For example, if you are hosting SAP HANA in a cloud instance then your URL may look like this:
  6. Check the Use Credentials checkbox and select the New ZS-HTTP Connection option.
  7. In HTTP Connection Manager select the Basic Authentication option and enter your SAP HANA UserID / Password.
    Configure SSIS HTTP Connection (SAP S4 / HANA OData Service - Using Basic Authentication)

    Configure SSIS HTTP Connection (SAP S4 / HANA OData Service – Using Basic Authentication)

  8. Let’s get back to the XML Source connector we created in the previous stage. Press the Select Filter button or directly type $.feed.entry[*]  into the field as shown below:
    Select Filter for OData Service (XML REST API)

    Select Filter for OData Service (XML REST API)

  9. Click Preview to make sure you can see the records.
  10. Click OK to save the configuration and close the configuration window.

In the next section, we will configure the target to load SAP data into SQL Server using the ZappySys Upsert Destination Data Flow component.

Load SAP HANA data into SQL Server using Upsert Destination

Now let's look at how to load data into target like SQL Server, Oracle or Flat File. In below example we will see loading data into SQL Server database but steps may remain same for other targets which can be accessed using OLEDB Drivers (e.g. Oracle).
  1. Inside Data Flow, Drag and drop Upsert Destination Component from SSIS Toolbox
  2. Connect our Source component to Upsert Destination
  3. Double click Upsert Destination to configure it
  4. Select Target Connection or click NEW to create new connectionConfigure SSIS Upsert Destination Connection - Loading data (REST / SOAP / JSON / XML /CSV) into SQL Server or other target using SSIS Configure SSIS Upsert Destination Connection - Loading data (REST / SOAP / JSON / XML /CSV) into SQL Server or other target using SSIS
  5. Select Target Table or click NEW to create new table based on source columns
  6. Click on Mappings Tab to Auto map columns by name. You can change mappings as you need SSIS Upsert Destination - Columns Mappings SSIS Upsert Destination - Columns Mappings
  7. Click OK to Save Upsert Destination Settings
  8. That's it, You are now ready to run data flow. NOTE: If you wish to debug data flow and see records when you run, add data viewer by right click on blue arrow > Click Enable Data Viewer
  9. To execute data flow, Right click anywhere inside Data Flow Surface and click Execute Task
 

Conclusion

In this post, we saw how easy it is to read SAP S4 HANA data using XML Source SSIS connector that is part of ZappySys SSIS PowerPack. Download it, try it out, and see it for yourself! It has many more connectors that were not mentioned in this post but could be also very helpful in your daily work.

Posted in REST API Integration, SSIS Upsert Destination, SSIS XML Source (File / SOAP) and tagged , , , , , .