Responding back to SAP from Logic App

So you've registered SAP as a trigger in Azure Logic Apps, enabling SAP to call it as for any other RFC. But how do you parse the SAP request and respond back to it with actual content and not just a vanilla OK?

If you enable the support for multiple RFCs by your Logic App for SAP to call, you need to arrange your logic by Action Uri, that trigger output json parameter which will contain which RFC got call by SAP. For this example we'll just consider a single RFC as a simplification - STFC_CONNECTION. The trigger has been configured for this one only, using the trigger input parameter action URI which causes the SAP Adapter in the On-Premises Data Gateway to act as a filter rejecting calls to other RFCs by SAP. [You can see an example of that in the summary picture at the bottom of this post.]

The next step is to get the XML payload of the SAP RFC call. This is in the trigger output Content parameter @triggerBody()?['Content'], but natively as a string (because Json doesn't have a type for XML). So you want to cast the type to XML with @xml(triggerBody()?['Content']).
Now Logic App knows this is XML as visible in the designer run history view:

To manipulate the XML we can use the X-PATH native support, and here we'll extract the SAP RFC STFC_CONNECTION request text value with @{xpath(xml(triggerBody()?['Content']),'string(/*[local-name()=\"STFC_CONNECTION\"]/*[local-name()=\"REQUTEXT\"])')}

Now we can use this extracted value to form a dynamic response to SAP with @{variables('REQUTEXTValue')}, such as in <STFC_CONNECTIONResponse xmlns=\"http://Microsoft.LobServices.Sap/2007/03/Rfc/\"><ECHOTEXT>@{variables('REQUTEXTValue')}</ECHOTEXT><RESPTEXT>Received</RESPTEXT></STFC_CONNECTIONResponse>

Calling from SAP Logon we can see the dynamic echo response:

For a more complete manipulation of the input request, consider converting the request XML to Json ( or transforming the XML with XSLT (

Here is the designer view for this whole Logic App:

Comments (1)

  1. David Burg says:

    A couple notes for people using the xpath example in different context than SAP connector:
    1. Make sure you have the right expression to get to the XML content. With the SAP connector trigger the XML content is wrapped in Json output of the trigger under the property Content, thus the expression is xml(triggerBody()?[‘Content’]). If you have a trigger like an HTTP trigger which whole payload is XML itself without a Json wrapper, the expression would be more simply xml(triggerBody()) (no ?[‘Content’])
    2. The XPATH example I provided only checks for the XML nodes names, not the namespace. You can check namespaces with an AND condition like this (/*[local-name()=\”NodeName\” and namespace-uri()=\”\”]

Skip to main content