Skip to Content
Author's profile photo Bartosz Jarkowski

Your SAP on Azure – Part 9 – Easy integration using Azure Logic Apps

Microsoft Azure is much more than just virtual machines. As soon as your account is created you get unlimited access to hundreds of features that you can easily use. I have already presented a few interesting scenarios where you can use a kubernets cluster to host multiple HANA databases or protect your landscape against unexpected events with integrated disaster recovery. Azure Logic Apps is another service that you can use to enhance and optimize SAP landscape. It allows you to build chains of actions and integrate SAP solution with external systems.

Today we are going to build two Logic Applications that can communicate with the SAP system. The first one will periodically scan the Microsoft OneDrive looking for new files which content will be used to create an IDoc. The second app will send us an e-mail notification as soon as the IDoc is sent from the application server.

CREATE LOGIC APPLICATION

To create your first workflow, enter the Logic Application pane and click +Add. Fill the form with the app name, resource group and the location. Confirm by clicking Create.

To build the Logic Apps you can use one of the already existing templates. It’s a great way to learn and understand how the workflows are designed and I highly recommend spending some time to review them.

Our scenario doesn’t have a predefined template so I choose to create a Blank Logic App.

Each workflow is executed by a trigger that is associated with an application we want to integrate. You can choose from a wide range of connectors to popular online services like Office 365, Salesforce, Twitter and many others. If you can’t find one you can also use a generic trigger that listens for HTTP requests.

A OneDrive connector is already built-in and exposes five triggers that start the workflow.

The connector configuration is simple and basically comes to providing required authorization to Azure Platform and selecting a directory that should be monitored.

The communication between Logic App and SAP system will be handled by HTTP connector that builds and transmits web requests. The configuration is more complex and gives you the control over the request headers and body, authentication and cookies. The message will be composed by reading the file content.

To enable the communication your SAP system has to listen for HTTP requests and the ICF node /sap/bc/idoc_xml has to be active.

I’m going to use the FLIGHTBOOKING_CREATEFROMDAT01 IDoc to verify the process. In WE20 I have created a new partner profile and defined the IDoc’s message type in the inbound parameters:

My sample IDoc used for testing:

<?xml version="1.0" encoding="UTF-8" ?>
<FLIGHTBOOKING_CREATEFROMDAT01>
	<IDOC BEGIN="1">
		<EDI_DC40 SEGMENT="1">
			<TABNAM>EDI_DC40</TABNAM>
			<MANDT>000</MANDT>
			<DOCREL>740</DOCREL>
			<STATUS>56</STATUS>
			<DIRECT>2</DIRECT>
			<OUTMOD/>
			<IDOCTYP>FLIGHTBOOKING_CREATEFROMDAT01</IDOCTYP>
			<CIMTYP/>
			<MESTYP>FLIGHTBOOKING_CREATEFROMDAT</MESTYP>
			<SNDPOR>0</SNDPOR>
			<SNDPRT>LS</SNDPRT>
			<SNDPRN>KT1CLNT000</SNDPRN>
			<RCVPOR>SAPKT1</RCVPOR>
			<RCVPRT>LS</RCVPRT>
			<RCVPRN>KT1CLNT000</RCVPRN>
			<CREDAT>20180923</CREDAT>
			<CRETIM>090207</CRETIM>
		</EDI_DC40>
		<E1SBO_CRE SEGMENT="1">
			<RESERVE_ONLY>X</RESERVE_ONLY>
			<TEST_RUN>X</TEST_RUN>
			<E1BPSBONEW SEGMENT="1">
				<AIRLINEID>LH</AIRLINEID>
				<CONNECTID>0400</CONNECTID>
				<FLIGHTDATE>21102018</FLIGHTDATE>
				<CUSTOMERID>00002542</CUSTOMERID>
				<CLASS>Y</CLASS>
				<COUNTER>00000000</COUNTER>
				<AGENCYNUM>00000087</AGENCYNUM>
				<PASSNAME>BARTOSZ JARKOWSKI</PASSNAME>
				<PASSBIRTH>03041986</PASSBIRTH>
			</E1BPSBONEW>
			<E1BPPAREX/>
		</E1SBO_CRE>
	</IDOC>
</FLIGHTBOOKING_CREATEFROMDAT01>

In order to start the test, click on the Run button in the Logic App designer and save the IDoc in the previously defined directory on OneDrive.

Once the job is finished the Azure displays a summary about each step.

You can click on a bar to more detailed information about the job execution. Let’s have a closer look to the HTTP request. The Inputs window displays how the message was constructed and where it was sent. The request body matches the content of the file.

The Outputs window tells you what happened to the message. Status code 200 means the IDoc was successfully received by SAP Application Server. In case of processing issues, you can also refer to the error message in response body.

A quick look to transaction WE20 to confirm the IDocs was imported:

A workflow can be easily enhanced by adding new steps. The bellow configuration will move each processed file to the archive directory and send an e-mail with processing status:

I have resent the same file again. This time the processing failed and l received e-mail notification:

RECEIVE IDOCS FROM SAP

The second workflow will be triggered when an IDoc is sent from the SAP Application Server. The application saves the content of the message on the OneDrive and sends an e-mail with notification.

Create a new Logic App and select HTTP Request to be the trigger.

We will re-use the parts from the first application to save the IDoc as a file and send it through e-mail.

To generate the IDocs in SAP Application Server it is required to define a new HTTP Connection pointing to the Logic App.

Now I create a port for outgoing IDocs referencing previously created HTTP destination:

I use WE19 to generate sample IDocs.

When the message is sent from SAP it triggers a workflow in the Logic App. Below you can see the summary of executed activities.

You can use Azure Logic Apps to build new integration or enhance already working scenarios. The today’s examples are just a small chunk of the workflow capabilities. I highly encourage you to create your own apps and discover more advanced features. The Logic Apps are a good alternative to expensive solutions like SAP PI or Microsoft BizTalk and it’s worth to deeply understand how can they help you to optimize your environment.

Assigned Tags

      9 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sashko Janev
      Sashko Janev

      Hi, and thanks for your post.

      I was wondering how your partner profile is set up for the Outbound IDOC test in we19 (for the RECEIVE IDOC FROM SAP part). I tried using the one I created for the inbound message type but when I test in we19 I am getting a warning message "Idoc was saved but cannot or should not be sent" (even though I changed the Receiver Port in the partner profile message type to LOGIC_APP).

      Also I created the HTTP Connection in SAP but when I run a connection test it says ICM_HTTP_CONNECTION_BROKEN. Are there additional steps I am missing that would help in mitigating these 2 issues?

      Thanks,

      Sashko

      Author's profile photo Bartosz Jarkowski
      Bartosz Jarkowski
      Blog Post Author

      Can you display the idoc in WE09 and check the status? You should see additional information helping you to find the root cause.

      Author's profile photo Naveen Mirdoddi
      Naveen Mirdoddi

      Hello ,

      My requirement is to send a message from SAP to AZURE Logic app and inside my app,I will call an external system and receive a URL , finally send the URL back to SAP.

      Really appreciate your above work.

       

      Can you shed some light or resources to look into for  my requirement.

       

      Appreciate your response.

       

      Thanks,

      NAveen

       

      Author's profile photo Naveen Mirdoddi
      Naveen Mirdoddi

      I figured out myself the solution.

       

      Will post soon as a separate blog..

      Regards,

      Naveen

       

       

       

       

      Author's profile photo David Burg
      David Burg

      Naveen could you share this solution or a link to your blog post?

      Author's profile photo David Burg
      David Burg

      Bartosz could you clarify the SSL settings that you used for the external HTTP RFC Destination? I assume one has to enable SSL as Azure Logic App HTTP trigger is of type HTTPS only.

      Also the Azure Logic App HTTP trigger has a mandatory query string with API version and auth token, but the external HTTP RFC Destination prefix does not allow a query string. Where do you input the query string?

      Author's profile photo Bartosz Jarkowski
      Bartosz Jarkowski
      Blog Post Author

      Hi David Burg,

      yes, as I'm accessing Logic Apps using HTTPS I activated the SSL on the Logon and Security tabs:

      In addition I had to add Logic App host certificate in STRUST:

      I've put query string in the path prefix - I remember it used to throw warnings, but I've just tested it and it was successfully saved without any warnings. Maybe it's related to SAP Netweaver release? Anyway even SAP suggest to ignore it:
      905077 - Warning "Query string not allowed"

      Author's profile photo Senthil Kumar
      Senthil Kumar

      Hi Bartosz Jarkowski,

      Issue : Azure logic app send IDoc message to SAP, where SAP takes time to process IDoc during peak hours and Azure didn't get a response code on specific time. this leads Azure logic apps to re-send IDoc to SAP by default which creates duplicate IDoc (Assume SAP processed the first IDoc intermediately). Can you share insights to handle this issue in Azure?

       

      Regards,

      Senthil

      Author's profile photo Philippe Addor
      Philippe Addor

      Hi Senthil

      I don't know about Logic Apps. But I would suggest to switch the partner profile for the idoc to "background processing instead" of "immedate processing".  In this case, SAP terminates the conneciton and you can let a background job process the IDocs.

      Philippe