Red Hat Training

A Red Hat training course is available for Red Hat Fuse

Chapter 102. SAP Component

Abstract

The SAP Component enables outbound and inbound communication to and from SAP systems using synchronous remote function calls, sRFC. The component uses the SAP Java Connector (SAP JCo) library to facilitate bidirectional communication with SAP. The component supports two types of endpoints: destination endpoints and server endpoints.

102.1. Overview

Dependencies

Maven users need to add the following dependency to their pom.xml file to use this component:
<dependency>
    <groupId>org.fusesource</groupId>
    <artifactId>camel-sap</artifactId>
    <version>x.x.x</version>
<dependency>

Deploying in a Fuse Fabric

A prerequisite for using the SAP component is that the SAP Java Connector (SAP JCo) libraries must be installed into the lib/ directory of the Java runtime (sapjco3.jar and libsapjco3.jnilib).
In the case of a Fuse Fabric deployment, this requires some special configuration. There is no point in simply installing the SAP JCo libraries in the Java lib directory on a single machine, because Fabric containers need to be deployable anywhere in the network. The correct approach is to define a special profile that is capable of downloading and installing the SAP JCo libraries on whichever host it is running on.
You can define a profile for the SAP JCo libraries as follows:
  1. Deploy the JCo libraries (sapjco3.jar and libsapjco3.jnilib) to a network accessible location. For example, you could install the libraries in a Web server, so that the JCo libraries can be downloaded through HTTP URLs, http://mywebserver/sapjco3.jar and http://mywebserver/libsapjco3.jnilib.
  2. Create a new profile, camel-sap-profile, by entering the following console command:
    JBossFuse:karaf@root> profile-create camel-sap-profile
  3. Edit the agent properties of the camel-sap-profile profile, by entering the following console command:
    JBossFuse:karaf@root> profile-edit camel-sap-profile
  4. The built-in profile editor starts up. Use this built-in text editor to add the following contents to the agent properties:
    # Profile:my-camel-sap-profile
    attribute.parents = feature-camel
    
    # Deploy JCo3 Libs to Container
    lib.sapjco3.jar = http://mywebserver/sapjco3.jar
    lib.sapjco3.jnilib = http://mywebserver/libsapjco3.jnilib
    
    # Append JCo3 Packages to OSGi system property
    # in order to expose JCo3 classes to OSGi environment
    config.org.osgi.framework.system.packages.extra= \
        ... Packages from etc/config.properties file ...\
        com.sap.conn.jco, \
        com.sap.conn.jco.ext, \
        com.sap.conn.jco.monitor, \
        com.sap.conn.jco.rt, \
        com.sap.conn.jco.server
    Customize the property settings as follows:
    lib.sapjco3.jar
    Customize the HTTP URL to the actual location of the sapjco3.jar file on your Web server.
    lib.sapjco3.jnilib
    Customize the HTTP URL to the actual location of the libsapjco3.jnilib file on your Web server.
    lib.sapidoc3.jar
    Customize the HTTP URL to the actual location of the sapidoc3.jar file on your Web server.
    config.org.osgi.framework.system.packages.extra
    Open the container configuration properties file, etc/config.properties, of your JBoss Fuse installation and look for the org.osgi.framework.system.packages.extra property setting. Copy the list of packages from that setting and paste them into the profile's agent properties, replacing the line:
        ... Packages from etc/config.properties file ...\
    Note
    The config.* prefix in config.org.osgi.framework.system.packages.extra indicates to Fabric that you are setting a container configuration property in the profile.
    Note
    The backslash, \, is the line continuation character (UNIX convention) and must be followed immediately by a newline character.
    Type Ctrl-S to save the properties when you are finished.
  5. You can now deploy the camel-sap-profile profile to any Fabric container where you want to run the SAP component. For example, to deploy the camel-sap-profileprofile to the sap-instance container:
    JBossFuse:karaf@root> container-add-profile sap-instance came-sap-profile

URI format

The URI scheme for an SAP component is as follows:
sap:[destination:destinationName|server:serverName]rfcName?options
The destination: prefix designates a destination endpoint and destinationName is the name of a specific outbound connection to an SAP instance. Outbound connections are named and configured at the component level, as described in Section 102.4, “Destination Configuration”. The rfcName in a destination endpoint URI is the name of the RFC invoked by the endpoint in the connected SAP instance.
The server: prefix designates a server endpoint and serverName is the name of a specific inbound connection from an SAP instance. Inbound connections are named and configured at the component level, as described in the Section 102.5, “Server Configuration”. The rfcName in a server endpoint URI is the name of the RFC handled by the endpoint when invoked from the connected SAP instance.
Note
Server endpoints do not currently support any options.

URI options for destination endpoints

The following table summarizes the options supported by the URI for destination endpoints:
NameDefaultDescription
transactedfalse
When true, the endpoint will join or initiate a SAP transaction invoking an RFC call.

SAP destination endpoint

A destination endpoint supports outbound communication to SAP, which enable these endpoints to make RFC calls out to ABAP function modules in SAP. A destination endpoint is configured to make an RFC call to a specific ABAP function over a specific connection to an SAP instance. A destination is a logical designation for an outbound connection and has a unique name. A destination is specified by a set of connection parameters called destination data.
A destination endpoint will extract an RFC request from the input message of the IN-OUT exchanges it receives and dispatch that request in a function call to SAP. The response from the function call will be returned in the output message of the exchange. Since SAP destination endpoints only support outbound communication, a destination endpoint will only support the creation of producers.

SAP server endpoint

A server endpoint supports inbound communication from SAP, which enables ABAP applications in SAP to make RFC calls into server endpoints. An ABAP application interacts with a server endpoint as if it were a remote function module. A server endpoint is configured to receive an RFC call to a specific RFC function over a specific connection from an SAP instance. A server is a logical designation for an inbound connection and has a unique name. A server is specified by a set of connection parameters called server data.
A server endpoint will handle an incoming RFC request and dispatch it as the input message of an IN-OUT exchange. The output message of the exchange will be returned as the response of the RFC call. Since SAP server endpoints only support inbound communication, a server endpoint will only support the creation of consumers.

Meta-data repositories

A meta-data repository is used to store and provide interface descriptions of function modules. This meta-data is used by the JCo and ABAP runtimes to check RFC calls to ensure the type-safe transfer of data between communication partners before dispatching those calls. A repository is populated with repository data. Repository data is a map of named function templates. A function template contains the meta-data describing all the parameters and their typing information passed to and from a function module and has the unique name of the function module it describes.
SAP destination and server endpoints thus require access to a repository in order to send and receive RFC calls and the meta-data for all function modules invoked and handled by the endpoints must reside within a repository. The location of the repository used by a destination and server endpoint is specified in destination and server data of their respective connections.
In the case of an SAP destination endpoint, the repository it uses typically resides in an SAP system and it defaults to the SAP system it is connected to. This default requires no explicit configuration in the destination data. Furthermore, the meta-data for the remote function call that a destination endpoint makes will already exist in a repository for any existing function module that it calls. The meta-data for calls made by destination endpoints thus require no configuration in the SAP component.
On the other hand, the meta-data for function calls handled by server endpoints do not typically reside in the repository of an SAP system and must instead be provided by a repository residing in the SAP component. The SAP component maintains a map of named meta-data repositories. The name of a repository corresponds to the name of the server to which it provides meta-data.