Nav

SAP Connector

Premium

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

Note: This connector is only available in Studio 7 and 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.

Prerequisites

This document assumes that you are familiar with Mule, Anypoint Connectors, and Anypoint Studio.

This document also 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.

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

What’s New in this Connector

This version of the connector drops support for Mule 3.x and adds support for Mule 4.x. Besides this, no functionality was added or removed.

To Connect in Design Center

This connector version is not supported in Design Center.

Install the SAP Connector in Studio

  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.

Configure in Studio

To use the SAP connector in your Mule application, you can configure 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

Username of an authorized SAP user.

Password

Password credential of an authorized SAP user.

System Number

System number used to connect to the SAP system.

Client

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.

Configuring the Connector in Studio 7

  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.dll, sapjco3.dll, libsapjco3.dll

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

    • Linux: sapidoc3.jar, sapjco3.jar, libsapjco3.so

  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.

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

name

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

Default idocument Version

defaultIdocumentVersion

This version is used when sending the IDoc. Values for the IDoc version correspond to IDOC_VERSION_xxxx constants in com.sap.conn.idoc.IDocFactory.

Disable Function template cache flag

disableFunctionTemplateCacheFlag

Indicates if the function template cache should be disabled.

false

Evaluate response flag

evaluateResponseFlag

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

false

Log trace flag

logTraceFlag

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

false

Configuring for XML and Maven

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.


         
      
1
2
3
4
5
6
<dependency>
  <groupId>org.mule.connectors</groupId>
  <artifactId>mule-sap-connector</artifactId>
  <version>4.0.0</version>
  <classifier>mule-plugin</classifier>
</dependency>

Inside the <version> tags, put the desired version number, the word RELEASE for the latest release, or SNAPSHOT for the latest available version. The available version is: 4.0.0.

Use Case: Send an IDocument to SAP

The use case describes how to create a Mule application to send an IDocument 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 a HTTP endpoint onto the canvas and configure the following parameters:

    Parameter Value

    Connector Configuration

    HTTP_Listener_Configuration

    Path

    /sendIDoc

  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 (name of the global element you have created)

    Key

    MATMAS01

    Content

    #[payload]

  8. Drag a Transform Message component before the SAP connector, then 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 similar to the following:

    
                
             
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    %dw 2.0
    output application/xml
    ---
    read('<?xml version="1.0"?>
    <MATMAS01>
        <IDOC BEGIN="1">
            <EDI_DC40 SEGMENT="1">
                 <TABNAM>EDI_DC40</TABNAM>
                <MANDT>800</MANDT>
            </EDI_DC40>
        </IDOC>
    </MATMAS01>
    ',"application/xml")
  9. Add a Logger right after the SAP endpoint to see the connector payload in the logs.

  10. Save and Run as Mule Application.

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

    http://localhost:8081/sendIDoc

    Mule conducts the query, and adds the Employee record to NetSuite.

Use Case: XML


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
        xmlns:sap="http://www.mulesoft.org/schema/mule/sap"
        xmlns:http="http://www.mulesoft.org/schema/mule/http"
        xmlns="http://www.mulesoft.org/schema/mule/core"
        xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
        http://www.mulesoft.org/schema/mule/core/current/mule.xsd
        http://www.mulesoft.org/schema/mule/http
        http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
        http://www.mulesoft.org/schema/mule/sap
        http://www.mulesoft.org/schema/mule/sap/current/mule-sap.xsd
        http://www.mulesoft.org/schema/mule/ee/core
        http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
        <configuration-properties file="mule-artifact.properties"/>
        <sap:outbound-config name="SAP_Outbound" doc:name="SAP Outbound" >
                <sap:simple-connection-provider-connection
                applicationServerHost="${sap.jcoAsHost}"
                username="${sap.jcoUser}"
                password="${sap.jcoPasswd}"
                systemNumber="${sap.jcoSysnr}"
                client="${sap.jcoClient}"
                language="${sap.jcoLang}" />
        </sap:outbound-config>
        <http:listener-config name="HTTP_Listener_config"
        doc:name="HTTP Listener config" >
                <http:listener-connection host="0.0.0.0" port="8081" />
        </http:listener-config>
        <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"?>
<MATMAS01>
    <IDOC BEGIN="1">
        <EDI_DC40 SEGMENT="1">
             <TABNAM>EDI_DC40</TABNAM>
            <MANDT>800</MANDT>
        </EDI_DC40>
    </IDOC>
</MATMAS01>
',"application/xml")
]]></ee:set-payload>
                        </ee:message>
                </ee:transform>
                <sap:send config-ref="SAP_Outbound" doc:name="Send IDoc"  key="MATMAS01"/>
                <logger level="INFO" doc:name="Logger" message="#[payload]"/>
        </flow>
</mule>

SAP JCo Architecture

SAP JCo facilitates communication between an SAP backend system and a Java application. It allows Java programs to connect to SAP systems and invoke Remote Function Modules. It 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

  • Contact MuleSoft Support