Connect to SAP systems from Azure Logic Apps
This article shows how you can access your SAP resources from inside a logic app by using the SAP Application Server and SAP Message Server connectors. That way, you can automate tasks, processes, and workflows that manage your SAP data and resources by creating logic apps.
This example uses a logic app that you can trigger with an HTTP request. The logic app sends an Intermediate Document (IDoc) to an SAP server, and returns a response to the requestor that called the logic app. The current SAP connectors have actions, but not triggers, so this example uses the HTTP request trigger as the first step in the logic app's workflow. For SAP connector-specific technical information, see these reference articles:
If you don't have an Azure subscription yet, sign up for a free Azure account.
To follow along with this article, you need these items:
The logic app from where you want to access your SAP system and a trigger that starts your logic app's workflow. The SAP connectors currently provide only actions. If you're new to logic apps, review What is Azure Logic Apps and Quickstart: Create your first logic app.
Download and install the latest on-premises data gateway on any on-premises computer. Make sure you set up your gateway in the Azure portal before you continue. The gateway helps you securely access data and resources are on premises. For more information, see Install on-premises data gateway for Azure Logic Apps.
Download and install the latest SAP client library, which is currently SAP Connector (NCo) 220.127.116.11 for Microsoft .NET Framework 4.0 and Windows 64bit (x64), on the same computer as the on-premises data gateway. Install this version or later for these reasons:
Earlier SAP NCo versions can become deadlocked when more than one IDoc messages are sent at the same time. This condition blocks all later messages that are sent to the SAP destination, causing the messages to time out.
The on-premises data gateway runs only on 64-bit systems. Otherwise, you get a "bad image" error because the data gateway host service doesn't support 32-bit assemblies.
Both the data gateway host service and the Microsoft SAP Adapter use .NET Framework 4.5. The SAP NCo for .NET Framework 4.0 works with processes that use .NET runtime 4.0 to 4.7.1. The SAP NCo for .NET Framework 2.0 works with processes that use .NET runtime 2.0 to 3.5 and no longer works with the latest on-premises data gateway.
Message content you can send to your SAP server, such as a sample IDoc file. This content must be in XML format and include the namespace for the SAP action you want to use.
Add HTTP request trigger
In Azure Logic Apps, every logic app must start with a trigger, which fires when a specific event happens or when a specific condition is met. Each time the trigger fires, the Logic Apps engine creates a logic app instance and starts running your app's workflow.
In this example, you create a logic app with an endpoint in Azure so that you can send HTTP POST requests to your logic app. When your logic app receives these HTTP requests, the trigger fires and runs the next step in your workflow.
In the Azure portal, create a blank logic app, which opens the Logic App Designer.
In the search box, enter "http request" as your filter. From the triggers list, select this trigger: Request - When a HTTP request is received
Now save your logic app so you can generate an endpoint URL for your logic app. On the designer toolbar, choose Save.
The endpoint URL now appears in your trigger, for example:
Add SAP action
In Azure Logic Apps, an action is a step in your workflow that follows a trigger or another action. If you haven't added a trigger to your logic app yet and want to follow this example, add the trigger described in this section.
In the Logic App Designer, under the trigger, choose New step > Add an action.
In the search box, enter "sap server" as your filter. From the actions list, select the action for your SAP server:
- SAP Application Server - Send to SAP
- SAP Message Server - Send to SAP
This example uses this action: SAP Application Server - Send to SAP
If you're prompted for connection details, create your SAP connection now. Otherwise, if your connection already exists, continue with the next step so you can set up your SAP action.
Create on-premises SAP connection
For Gateways, select Connect via on-premises data gateway so that the on-premises connection properties appear.
Provide the connection information for your SAP server. For the gateway property, select the data gateway you created in the Azure portal for your gateway installation, for example:
SAP Application Server
SAP Message Server
When you're done, choose Create.
Logic Apps sets up and tests your connection, making sure that the connection works properly.
Now find and select an action from your SAP server.
In the SAP action box, choose the folder icon. From the folder list, find and select the action you want to use.
This example selects the IDOC category for the IDoc action.
If you can't find the action you want, you can manually enter a path, for example:
For more information about IDoc operations, see Message schemas for IDOC operations
Click inside the Input Message box so that the dynamic content list appears. In that list, under When a HTTP request is received, select the Body field.
This step includes the body content from your HTTP request trigger and sends that output to your SAP server.
When you're done, your SAP action looks like this example:
Save your logic app. On the designer toolbar, choose Save.
Add HTTP response action
Now add a response action to your logic app's workflow and include the output from the SAP action. That way, your logic app returns the results from your SAP server to the original requestor.
In the Logic App Designer, under the SAP action, choose New step > Add an action.
In the search box, enter "response" as your filter. From the actions list, select this action: Request - Response
Click inside the Body box so that the dynamic content list appears. From that list, under Send to SAP, select the Body field.
Save your logic app.
Test your logic app
If your logic app isn't already enabled, on your logic app menu, choose Overview. On the toolbar, choose Enable.
On the Logic App Designer toolbar, choose Run. This step manually starts your logic app.
Trigger your logic app by sending an HTTP POST request to the URL in your HTTP request trigger, and include your message content with your request. To the send the request, you can use a tool such as Postman.
For this article, the request sends an IDoc file, which must be in XML format and include the namespace for the SAP action you're using, for example:
<?xml version="1.0" encoding="UTF-8" ?> <Send xmlns="http://Microsoft.LobServices.Sap/2007/03/Idoc/3/ORDERS05//620/Send"> <idocData> <...> </idocData> </Send>
After you send your HTTP request, wait for the response from your logic app.
Your logic app might time out if all the steps required for the response don't finish within the request timeout limit. If this condition happens, requests might get blocked. To help you diagnose problems, learn how you can check and monitor your logic apps.
Congratulations, you've now created a logic app that can communicate with your SAP server. Now that you've set up an SAP connection for your logic app, you can explore other available SAP actions, such as BAPI and RFC.
For technical details about the connector as described by the connectors' Swagger files, see these reference articles:
- For questions, visit the Azure Logic Apps forum.
- To submit or vote on feature ideas, visit the Logic Apps user feedback site.