Basic Principles of the SAP Connector
** NOTE: This SAP Connector works with Mule 1.x. Are you looking for the SAP Connector for Mule 2.x? **
This SAP transport for Mule provides connectivity with SAP R/3 systems using RFC and BAPI calls. The core engine of this transport is the SAP Java Connector (JCo) provided by SAP. The input and output data of these calls are XML payload. Two DTD files define the XML format of these files, they are provided within the distribution package of the SAP transport. A mock version of the JCo library is also provided in the distribution for testing purpose.
The last release of the SAP transport (1.1) enables both synchronous calls and asynchronous polling.
- Synchronous calls are managed by an outbound SAP endpoint, using the incoming message for overriding call parameters. The result of the RFC or BAPI call may then be forwarded to another outbound endpoint via a ChainingRouter.
- Asynchronous polling is managed by an inbound SAP endpoint, invoking at a given frequency a configured BAPI or RFC. The result is made available to the associated UMO.
Prerequisites
In order to properly use thie SAP Connector, you need :
- version 1.4.x or 1.5.x of Mule ESB
- a JCo 2.1 library (provided by SAP), the mock packaged in the distribution is only for testing purpose
Configuration of the SAP Connector
Several SAP connectors may be configured within a Mule configuration. This may be useful when a single Mule instance has to interact with multiple SAP servers. The configuration properties includes:
- the SAP connection parameters
- the polling frequency for asynchronous mode
| Property |
Description |
Required |
| pollingFrequency |
Polling frequency in ms |
Yes (if used aynchronously) |
| Property Map |
|
|
| Name |
jcoParameters |
Provides connection data for the back end connection |
| Property |
Description |
Required |
| jco.client.client |
SAP client number |
Yes |
| jco.client.user |
RFC/BAPI User |
Yes |
| jco.client.password |
RFC/BAPI User password |
Yes |
| jco.client.lang |
Language used for the established back end connection |
Yes |
| jco.client.sysnr |
SAP System number |
Yes |
| jco.client.ashost |
SAP server host name |
Yes |
Here is an example configuration:
<connector name="SAPConnector" className="fr.ippon.mule.providers.sapr3.SAPConnector">
<properties>
<property name="pollingFrequency" value="10000"/>
<map name="jcoParameters">
<property name="jco.client.client" value="001"/>
<property name="jco.client.user" value="SAP"/>
<property name="jco.client.passwd" value="secret"/>
<property name="jco.client.lang" value="EN"/>
<property name="jco.client.ashost" value="sap-host"/>
<property name="jco.client.sysnr" value="42"/>
</map>
</properties>
</connector>
URI of SAP Endpoints
The URI format of a SAP Endpoint is defined like that:
BAPI_CONFIG is a reference to a specific RFC/BAPI call. The connector will need an XML configuration file 'BAPI_CONFIG.xml' in the current classpath, this file may define the IMPORT, EXPORT, STRUCTURES et TABLES sections used for the function call.
Here is an URI example:
XML configuration for an SAP Endpoint
The XML configuration file referenced by the previous URI is more or less the input data used for the SAP function call. It is read by the SAP connector for each JCo function call and may contain parameter names with the syntax '$PARAM'. The values for these parameters shall be retrieved from the endpoint URI or from the incoming message (only for synchronous calls).
Here is an XML configuration example file:
<?xml version="1.0"?>
<!DOCTPYE rfc PUBLIC "-//Ippon Technologies //DTD sap-rfc XML V1.0//EN"
"http://www.ippon.fr/mule/sap/rfc-configuration.dtd">
<rfc id="RFC_READ_TABLE" version="1.0">
<import>
<field name="QUERY_TABLE">DD02T</field>
<field name="ROWCOUNT">$ROWCOUNT</field>
</import>
</rfc>
If this file is associated with the previous example endpoint URI, the SAP connector shall replace $ROWCOUNT by the value '7' provided in the URI for the actual input data.
Asynchronous polling configuration
The SAP function call is invoked automatically at a given time frequency. The output data of the call is provided to the configured UMO as a DOM object.
Configuration example
<mule-descriptor name="sap" implementation="org.mule.components.simple.BridgeComponent">
<inbound-router>
<endpoint address="bapi://QUERY_TABLE_DD02T?ROWCOUNT=7" connector="SAPConnector"/>
</inbound-router>
<outbound-router>
<router className="org.mule.routing.outbound.OutboundPassThroughRouter">
<endpoint address="stream://System.out" transformers="DOMToStringTransformer"/>
</router>
</outbound-router>
</mule-descriptor>
Synchronous call configuration
A SAP endpoint can be configured to invoke a SAP function call on receiving a message from an UMO. There are two different URI format available in this case.
The URI may reference an XML configuration file (bapi://BAPI_CONFIG[?PARAM1=VALUE1[&PARAM2=VALUE2[&...]]], see above) or may be 'bapi://dom' in which case the incoming message will be used in place of the configuration file.
Configuration example with XML function call description
<mule-descriptor name="sap" implementation="org.mule.components.simple.BridgeComponent">
<inbound-router>
<endpoint address="stream://System.in" synchronous="true"/>
</inbound-router>
<outbound-router>
<router className="org.mule.routing.outbound.ChainingRouter">
<endpoint address="bapi://QUERY_TABLE_DD02T?ROWCOUNT=7" connector="SAPConnector"/>
<endpoint address="stream://System.out" transformers="DOMToStringTransformer"/>
</router>
</outbound-router>
</mule-descriptor>
In this example, a Birdge UMO receive a String from the standard input and forward it to the SAP endpoint. The input String may contain parameters that can override those defined in the URI. For example, if the user types 'ROWCOUNT=10', the ROWCOUNT value used as input parameter shall be '10' and not '7'.
Configuration example with 'bapi://dom'
<mule-descriptor name="sap" implementation="fr.ippon.mule.components.RfcReadTableDOMComponent">
<inbound-router>
<endpoint address="stream://System.in" synchronous="true"/>
</inbound-router>
<outbound-router>
<router className="org.mule.routing.outbound.ChainingRouter">
<endpoint address="bapi://dom" connector="SAPConnector"/>
<endpoint address="stream://System.out" transformers="DOMToStringTransformer"/>
</router>
</outbound-router>
</mule-descriptor>
When this endpoint URI syntax is used, the SAP connector must receive a DOM object in the incoming message from the UMO. The XML format of this DOM object is defined by the rfc-configuration.dtd and is similar to the previously used XML configuration file.
XML Syntax (similar to SE37)
| Element |
Description |
Attributes |
| rfc |
Starts decribing a certain RFC module |
@id: SAP Function module name (required) |
| import |
Container for import elements |
- |
| export |
Container for export elements (used for return values only) |
- |
| tables |
Container for tables |
- |
| structure |
Container for fields |
@name: Name of the structure (optional) |
| table |
Container for rows |
@name: Name of the table (required) |
| Row |
Container for structures or fields |
@id: Row number of the table row (optional) |
| Field |
Data field |
@name: SAP name of the field (required) |