Contact Free trial Login

SAP Connector for Mule 4

Support Category: Premium

SAP Connector v4.1 and v4.2

The SAP connector enables the integration of data to and from SAP NetWeaver-based and external systems.

Note: This connector is only available in Mule 4 and Studio 7, and is not available in the Design Center feature of Anypoint Platform.

This connector requires a separate license. Contact MuleSoft to evaluate or use this connector in production.

Mule runtime supports SAP integration through our Anypoint Connector for SAP, an SAP-certified Java connector that leverages the SAP Java Connector (JCo) libraries, thus allowing Mule applications to:

  • Execute BAPI functions over the RFC protocol, supporting the following types:

    • Synchronous RFC (sRFC)

    • Transactional RFC (tRFC)

    • Queued RFC (qRFC)

  • Act as a JCo Server to be called as a BAPI over sRFC, tRFC, and qRFC.

  • Send IDocs over tRFC and qRFC.

  • Receive IDocs over tRFC and qRFC.

  • Transform SAP objects (JCo Function/BAPI & IDocs) to and from XML.


This document assumes you have:

  • A working knowledge of the SAP business context and in particular, the SAP R/3 Business Suite.

  • A basic understanding of the SAP NetWeaver Platform from an administration point of view.

  • Knowledge of the ABAP language.

  • Login credentials to test your connection to your target resource.

For hardware and software requirements and compatibility information, see the SAP Connector Release Notes.

Note: This connector version is not supported for use in Design Center.

XML and Maven Support

To use this connector with Maven, view the pom.xml dependency information in the Dependency Snippets in Anypoint Exchange.

For Maven dependency management, include this XML snippet in your pom.xml file.


Inside the <version> tags, put the desired version number, the word RELEASE for the latest release, or SNAPSHOT for the latest available version. Possible versions are: 4.0.0, 4.0.1, 4.1.0, 4.1.1, 4.1.2, 4.1.3, 4.1.4, 4.1.5, 4.1.6, 4.2.0.

For JCo library support, add these dependencies:


Configure Studio for the Connector

  1. In Anypoint Studio, click the Exchange icon in the Studio task bar.

  2. Click Login in Anypoint Exchange and supply your Anypoint Platform username and password.

  3. Search for the SAP connector and click Install.

  4. Follow the prompts to install the connector.

Create a Global Element in Studio

If needed, you can create a global SAP element if you need more than one SAP connector instance in your Mule project.

The SAP connector object holds the configuration properties that allow you to connect to the SAP server.

To create a configuration for an SAP connector, complete the following steps:

  1. Go to Global Elements section, and click Create.

  2. Select either SAP Inbound or SAP Outbound in the Connector Configuration section

  3. In the General tab pane, enter the required parameters for defining an SAP connection, which your SAP system administrator should supply.

The SAP Global Element Configuration allows you to define connection properties as well as to easily add the required SAP dependencies to your project.

For ease of use, the SAP connector only shows the most common properties as connector parameters. To configure a property that is not listed in the Properties panel, consult the "Extended Properties" section in this guide.

The minimum required attributes to define are:

Field Description

Application Server Host

SAP endpoint


Username of an authorized SAP user.


Password credential of an authorized SAP user.

System Number

System number used to connect to the SAP system.


The SAP client ID (usually a number) used to connect to the SAP system.

Login Language

The language to use for the SAP connection. For example, EN for English.

As a best practice, use property placeholder syntax to load the credentials in a more simple and reusable way.

Click the Test button to verify that the connection to the SAP instance succeeded. If the credentials are correct you should receive a Test Connection Successful message.

Install SAP Libraries

  1. Browse to the SAP web site and download the version 3.0.18 libraries for IDOC, JCO, and JCO Native. The library formats are usable by Studio 7 directly without conversion. You can download them to a folder on your computer. You must have a SAP ID to download the libraries.

    Note: The file types for each library depend on your operating system:

    • Windows: sapidoc3.jar, sapjco3.jar, sapjco3.dll

    • Mac OS: sapidoc3.jar, sapjco3.jar, libsapjco3.jnilib

    • Linux: sapidoc3.jar, sapjco3.jar,

  2. After installing the SAP connector in Studio and adding the connector to your Mule project, double click the connector in the flow, and click the plus (+) sign to the right of the Connector Configuration field.

    This screen appears:

    SAP Outbound Configuration in Studio

    All three Add Dependency configurations are required to configure the SAP connector:

Install the IDOC Library

  1. Click Add Dependency.

  2. Click Install.

    Maven dependency for IDOC
  3. In the Install menu, click Browse to locate the library file.

  4. Specify a unique Group ID, Artifact ID, and version.

    Maven dependency for IDOC

    When done, click Finish or if you want to cancel, click Remove Dependency.

    Finish IDOC install screen

Install the JCO Library

  1. Click Add Dependency.

  2. Click Install.

    Maven dependency for JCO
  3. In the Install menu, click Browse to locate the library file.

  4. Specify a unique Group ID, Artifact ID, and version.

    Maven dependency for JCO

    When done, click Finish or if you want to cancel, click Remove Dependency.

    Finish JCO install screen

Install the JCO Native Library

  1. Click Add Dependency.

  2. Click Install.

    Maven dependency for JCO Native
  3. In the Install menu, click Browse to locate the library file.

  4. Specify a unique Group ID, Artifact ID, and version.

    Maven dependency for JCO Native

    When done, click Finish or if you want to cancel, click Remove Dependency.

    Finish JCO Native install screen

When Done Installing Libraries

When done, the configuration screen appears as follows with green check marks for each successfully installed library:

All dependent libraries installed
  1. Add values for the remaining Global Element Properties fields as described in the Configure in Studio section. All the information is available from your SAP site access.

  2. Click Test Connection to ensure that you have the correct login information.

Define Extended Properties

To define extended properties for the SAP connector global element, complete the following steps:

  1. Navigate to the Advanced tab on the General pane:

    Lower Advanced Tab
  2. Locate the Extended Properties section at the top of the window.

  3. Select the Edit inline option.

  4. Click the plus button ('+') to add a new extended property.

For this to work you must set the property name, as defined by SAP, in your configuration.

SAP Inbound

There are no special Advanced properties for this configuration.

SAP Outbound

Field XML Attribute Description Default Value

Display Name


The reference name of the endpoint used internally by Mule configuration.



Canonical name of an encoding. See Oracle’s Supported Encodings.

Default idocument Version


This version is used when sending the IDoc. Values for the IDoc version correspond to IDOC_VERSION_xxxx constants in

Disable Function template cache flag


Indicates if the function template cache should be disabled.


Evaluate response flag


Indicates if an error response should throw an exception or let the user handle it as another result.


Log trace flag


Indicates if the trace should be logged on the Mule server.


Use SAP default format


Indicates to use SAP default format when working with BAPI functions over sRFC.


Operation timeout


Timeout for operations. A positive value in milliseconds. A value of 0 means indefinite waiting.


Use Case: Function Source - Return Values to SAP

Create a Mule application that receives a function using the SAP connector’s Function source operation. The Function source operation passes the export parameter back to SAP.

  1. Create a new Mule Project in Anypoint Studio.

  2. Add the SAP connector to your project.

  3. Drag the SAP connector’s Function source operation to the flow.

  4. Create a new SAP Inbound global element configuration and fill with environment values.

  5. Add a transform message component to the flow and fill the details based on metadata.


    sap function return response

    The flow should look like this:

    sap flow response

    In the SAP Studio interface, you should see:

    sap result sap gui

Send IDoc to SAP

To create a Mule application to send an IDoc to SAP:

  1. Create a new Mule Project in Anypoint Studio.

  2. Create a new HTTP Listener global element configuration and leave it with the default values.

  3. Drag an HTTP Request connector onto the canvas and configure the following parameters:

    Parameter Value

    Connector Configuration




  4. Create a new SAP Outbound global element configuration and fill with environment values.

  5. Click Test to confirm that Mule can connect with the SAP instance. If the connection is successful, click OK to save the configuration. Otherwise, review or correct any invalid parameters and test again.

  6. Select the SAP module and add Send IDoc operation next to the HTTP and in the Extension Configuration field select the configuration created in the previous section.

  7. Configure the operation with the following values:

    Parameter Value

    Display Name

    Send IDoc (or any other name you prefer).

    Connector configuration

    SAP_Outbound - The name of the global element you created.





  8. Drag a Transform Message component before the SAP connector, and click the component to open its properties editor. Once metadata has been retrieved, select the respective fields to populate for the Employee. The Transform script should look like:

    %dw 2.0
    output application/xml
    read('<?xml version="1.0"?>
        <IDOC BEGIN="1">
            <EDI_DC40 SEGMENT="1">
  9. Add a Logger right after the SAP endpoint to see the connector payload in the logs.

  10. Save and Run as a Mule Application.

  11. From a web browser, test the application by entering an employee’s internal Id, first name, and last name in the form of the following query parameters:


    Mule conducts the query and adds the employee record.

XML for Send IDoc to SAP

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee=""
    <configuration-properties file=""/>
    <sap:outbound-config name="SAP_Outbound" doc:name="SAP Outbound" >
        language="${sap.jcoLang}" />
    <http:listener-config name="HTTP_Listener_config"
      doc:name="HTTP Listener config" >
        <http:listener-connection host="" port="8081" />
    <flow name="demo-idoc-clientFlow"  >
        <http:listener config-ref="HTTP_Listener_config"
        path="/idoc" doc:name="Listener"  />
        <ee:transform doc:name="Transform Message" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
output application/xml
read('<?xml version="1.0"?>
    <IDOC BEGIN="1">
        <EDI_DC40 SEGMENT="1">
    <sap:send config-ref="SAP_Outbound" doc:name="Send IDoc"
    <logger level="INFO" doc:name="Logger" message="#[payload]"/>

SAP JCo Notes

SAP JCo facilitates communication between an SAP backend system and a Java application. SAP JCo allows Java programs to connect to SAP systems and invoke Remote Function Modules. SAP JCo also allows parsing of IDocs (SAP Intermediate Documents), among other object types. Both inbound and outbound communications are supported.

  • Java API: Handles dynamic metadata lookup and caching. It implements JCO.Function, which is the container for parameters and/or tables for the SAP Function Module (BAPI) in Java. Java applications are built on top of the Java API.

  • JNI (Java Native Interface): Originally, SAP created libraries in C language to allow direct RFC calls to SAP, to manipulate with data. JCo wraps C libraries in Java to provide platform-native access into the SAP system. RFC Middleware uses RFC Library through (JNI) Layer.

  • 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.

  • RFC Library: Libraries of C language-based functions to access the SAP system. RFC library is addressed by JNI.

  • RFC Layer: SAP component that processes RFC calls.

  • SAP Java IDoc Class Library: Provides structured, high-level interpretation and navigation of SAP IDocs in Java. It consists of the following add-on packages:

    • SAP Java Base IDoc Class Library: a middleware-independent library that provides a set of general base classes and interfaces for middleware dependent Java IDoc Class Library implementations.

    • SAP Java Connector IDoc Class Library: A middleware-independent library for creating, sending, and receiving IDocs.

  • FM (Function Module): Function modules are procedures that are defined in the ABAP language of SAP. It allows the encapsulation and reuse of global functions in the SAP System.

  • BAPI (Business Application Programming Interface): The Function Module that fulfills certain design criteria, such as:

    • Implements a method of a SAP Business Object.

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

    • Is remote-enabled.

    • Runs to completion with or without user interaction.

    • Handles errors.

  • IDoc (Intermediate Document): Standard SAP format for electronic data interchange between SAP systems. Different messages types (such as delivery notes or purchase orders) generally correspond to different special formats, known as IDoc types. Multiple message types with related content can, however, be assigned to a single IDoc type.

  • ALE (Application Link Enabling): Technology for setting up and operating distributed applications. ALE facilitates distributed, yet integrated, installation of SAP systems. This involves business-driven message exchange using consistent data across loosely linked SAP applications. Applications are integrated through synchronous and asynchronous communication, rather than by use of a central database.

  • SAP NetWeaver: One of the main technologies and application platforms used by SAP solutions. Its main component is the SAP Web Application Server (WebAS), which provides the runtime environment for SAP applications like ERP, CRM, SCM, PLM, SRM, BI. Other components include enterprise portal, exchange infrastructure, master data management and mobile infrastructure. The SAP NetWeaver is an umbrella term for these technical components.

  • SAP NetWeaver runs on both Java and ABAP stacks.

  • ABAP (Advanced Business Application Programming): SAP’s proprietary programming language and part of the NetWeaver platform for building business applications.

See Also

  • The SAP connector uses the RFC protocol to connect to NetWeaver Application Servers (NWAS)

  • ECC and CRM run on top of NWAS, as other SAP solutions do, and hence any customer using the connector may access those systems

  • MuleSoft Forum

  • Knowledge Base Articles

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub