MuleSoft SAP Integration

Gursimran Singh Ranhotra
Another Integration Blog
5 min readJun 6, 2023

In this article, we would discuss regarding Mulesoft and SAP Integration.
MuleSoft’s SAP connector helps you to integrate different on-premise and cloud-based business applications with SAP ERP Central Component (ECC) or SAP S/4HANA on-premises, via RFC.

It enables real-time integration of digital information across your business from Financial Accounting, Controlling, and Materials Management, to Sales and Distribution, and Customer Service. This connector helps you to obtain a unified view of enterprise resources, thereby enabling you to make data-driven decisions that optimize core business processes.

The SAP JCo libraries enable Mule apps to:

  • Execute BAPI functions over the following types of RFC protocols:

1. Synchronous Remote Function Call RFC (sRFC)

2. Asynchronous Remote Function Call RFC (aRFC)

  • Act as a JCo server to be called as a BAPI over sRFC and aRFC
  • Send IDocs over tRFC and qRFC
  • Receive IDocs over tRFC and qRFC
  • Transform SAP objects (JCo function for BAPI and IDocs) to and from XML

Let us go over these in depth using hands-on examples.

Important terminologies:

Let’s go over some key SAP terms that will help you understand the rest of this article-

RFC (Remote Function Call): communication with the SAP system is performed over the RFC protocol. RFC means calling BAPI or triggering IDoc processing that runs in another system as calling program. The RFC interface enables function calls between two SAP systems or between the SAP and external system.

BAPI (Business Application Programming Interface):
It is the Function Module that fulfills certain design criteria, such as:

  1. Implements a method of a SAP Business Object.

2. Maintains a static interface through different versions of the SAP system.

3. Enable remotely and handle errors.

IDoc (intermediate document)-

IDoc is the standard SAP format for electronic data interchange between SAP systems. Different message types generally correspond to different special formats, known as IDoc types.

SAP Synchronous RFC- It executes a BAPI function over a synchronous remote function call. RFC requires both the systems (client and server) to be available at the time of communication or data transfer.

SAP Asynchronous RFC- It executes a BAPI function over a queued remote function call. A qRFC is an extension of a transactional RFC (tRFC) that ensures that individual steps are processed in sequence.

SAP RFC Connector Guide-

  1. Installing SAP connector & configuring its Libraries-

The SAP connector is not by default available in the AnyPoint Studio palette. You can download SAP connector from exchange.

•You can get all these below libraries from SAP Marketplace.
You can download all of them in local and import them by clicking on- Configure -> Use local file.

For Windows-

  • sapidoc3.jar
    sapjco3.jar
    sapjco3.dll

For Mac OS-

  • sapidoc3.jar
    sapjco3.jar
    libsapjco3.jnilib

Kidnly note the JCo native library is OS specific

2. Enter the SAP client configurations listed below to connect to SAP Application Server-

Username
Password
SAP system Number
SAP System Client Id
Application server Host

We can test credentials and find out if they are valid-

3. Enter the SAP function name, which you want to execute-

In the case of an asynchronous RFC, you must also enter additional information, as shown in figure-

4. Keep a transform message before SAP connector, to see how its metadata is automatically populated.
We can create dataweave to form the required input for SAP-

Note- SAP connector generally accepts xml as input.

2. Using Mulesoft to send and retrieve Idocs from SAP-

1. Sending an IDoc to SAP-

The below article helps in configuring how to send idocs to SAP using SAP connector in Anypoint Studio-

  1. Test SAP connection(Installing SAP connector & configuring its Libraries and connection) as described earlier incase of RFC-

2. Give the iDoc name-

3. Keep a transform message before SAP connector, to see how its metadata is automatically populated.
We can create dataweave to form the required input for SAP-

Note- You will need the following fields from SAP System for sending Idocs-

TABNAM
MANDT
DIRECT
OUTMOD
IDOCTYP
MESTYP
SNDPOR
SNDPRT
SNDPRN
RCVPOR
RCVPRT
RCVPRN

And here, you’re ready to process , create & send idocs to SAP.

2. Receive an Incoming IDoc Request-

This below example shows you how to create a Mule app that waits for incoming IDoc requests from an external SAP system.
As soon as the app receives an IDoc request, it uses a remote function (RFC) call in order to ask SAP to create the IDoc.

  1. Test SAP connection(Installing SAP connector & configuring its Libraries and connection) as described earlier incase of RFC-

2. Configure the SAP RFC call and give the required iDoc name, as discussed earlier in case of RFC-

3. Configure the Document listener(Source) properties with the following values:

Fields-

Gateway host
Gateway service
Program id
Connection count
Idoc type filter regex

Note- The fields- Gateway host, Gateway service, and Program id must be Fetched from the SAP System.

Thanks for reading!
Please feel free to comment and follow me for more helpful articles and insights in the future.

--

--