<spring:bean name="sapProperties" class="java.util.HashMap">
<spring:constructor-arg>
<spring:map>
<spring:entry key="jco.client.client" value="100"/>
<spring:entry key="jco.client.user" value="SAP_USER"/>
<spring:entry key="jco.client.sysnr" value="00"/>
...
</spring:map>
</spring:constructor-arg>
</spring:bean>
SAP Connector Advanced Features
The SAP Connector provides a wide range of functionalities, beyond the basic ones already described in the SAP Connector Documentation. The present document will help you harness the full potential of your SAP Mule application.
JCo Extended Properties
The SAP connector provides a wide set of additional JCo properties allowing the user to configure the connection at the connector or endpoint level, inside the mule-config.xml
file.
The key names for these properties must match those expected by the JCo libraries. You can check them at SAP Client Properties and SAP Server Properties. |
These properties can be used inside the connector or endpoint elements by referencing a Spring Bean that contains a map with the extended attributes. This can be done by configuring the jcoClientExtendedProperties-ref
(inbound and outbound) or jcoServerExtendedProperties-ref
(inbound only):
<!-- connector -->
<sap:connector name="SapConnector" jcoClientExtendedProperties-ref="sapProperties" ... />
<!-- outbound - client props -->
<sap:outbound-endpoint connector-ref="sapConnector" jcoClientExtendedProperties-ref="sapProperties" ... />
<!-- inbound - client props -->
<sap:inbound-endpoint connector-ref="sapConnector" jcoClientExtendedProperties-ref="sapProperties" ... />
<!-- inbound - server props -->
<sap:inbound-endpoint connector-ref="sapConnector" jcoServerExtendedProperties-ref="sapProperties" ... />
The extended attributes can be configured in one of two ways (or using both methods combined):
Also, keep in mind the following:
|
JCo Client Properties
These are the properties that can be used inside the map-referenced attribute jcoClientExtendedProperties-ref
at connector or endpoint level (both inbound and outbound).
For an updated and complete list, check the Javadocs for |
SAP Property | Description | Mule Config Attribute | Default Value |
---|---|---|---|
|
SAP client |
|
|
|
Logon user |
|
|
|
Alias user name |
||
|
Logon password |
|
|
|
Logon language |
|
|
|
SAP system number |
|
|
|
SAP application server |
|
|
|
SAP message server |
||
|
Gateway host |
||
|
Gateway service |
||
|
R/3 name |
||
|
Group of SAP application servers |
||
|
Program ID of external server program |
||
|
Host of external server program |
||
|
Type of remote host |
||
|
Enable/disable RFC trace (0 or 1) |
|
|
|
Initial codepage in SAP notation |
||
|
Enable ABAP debugging 0 or 1 |
||
|
Use remote SAP graphical user interface (0/1/2) |
||
|
Get/Don’t get a SSO ticket after logon (1 or 0) |
||
|
Use the specified SAP Cookie Version 2 as logon ticket |
||
|
Use the specified X509 Certificate as logon ticket |
||
|
Enable/Disable logon check at open time, |
||
|
Additional data for GUI |
||
|
Host to which to redirect the remote GUI |
||
|
Service to which to redirect of the remote GUI |
||
|
Program ID of the server which starts the remote GUI |
||
|
Secure Network Connection (SNC) mode, |
||
|
SNC partner. For example, |
||
|
SNC level of security, 1 to 9 |
||
|
SNC name. Overrides default SNC partner |
||
|
Path to library which provides SNC service. |
||
|
R/2 destination |
||
|
String defined for SAPLOGON on 32-bit Windows |
||
|
Data for external authentication (PAS) |
||
|
Type of external authentication (PAS) |
||
|
Enable/Disable dsr support (0 or 1) |
||
|
Deny usage of initial passwords (0 default or 1) |
||
|
Maximum number of active connections that can be created for a destination, simultaneously |
|
|
|
Maximum number of idle connections kept open by the destination. A value of 0 has the effect that there is no connection pooling. |
|
|
|
Time in ms after that the connections hold by the internal pool can be closed. |
||
|
Interval in ms the timeout checker thread uses to check the connections in the pool for expiration |
||
|
Max time in ms to wait for a connection, if the max allowed number of connections is allocated by the application. |
||
|
Specifies the destination to be used as a repository, i.e. use this destination’s repository. |
||
|
Optional: if repository destination is not set, and this property is set, it will be considered as user for repository calls. This allows use of a different user for repository lookups. |
||
|
The password for a repository user. Mandatory, if a repository user should be used. |
||
|
Optional: if SNC is used for this destination, it is possible to turn it off for repository connections, if this property is set to 0. Defaults to the value of |
||
|
1 = force usage of |
Prioritizing Connection Properties
Properties for SAP connections, both inbound and outbound, can be configured in numerous places, which may cause an overlap of connection parameters. The following list details the priorities accorded to values specified in different places, with the highest priority level listed first.
-
Attributes defined at the SAP Inbound Endpoint and SAP Outbound Endpoint level, such as User, Password, Gateway Host, etc.
-
Properties in the Address attribute at the SAP Inbound Endpoint and SAP Outbound Endpoint levels. (However, MuleSoft does not recommend using the Address attribute for SAP connections.)
-
Properties inside the Map configured in the Extended Properties pane for the JCo client or server at the SAP Inbound Endpoint and SAP Outbound Endpoint levels.
-
Attributes configured at the SAP Connector Configuration level (that is, AS Host, User, Password, SAP Client, etc).
-
Properties inside the Map configured in the Extended Properties pane at the SAP Connector Configuration level.
-
Default values.
JCo Server Properties
These properties can be used inside the map-referenced attribute jcoServerExtendedProperties-ref
at inbound-endpoint level.
For an updated and complete list, check the Javadocs for |
SAP Property | Description | Mule Config Attribute | Default Value |
---|---|---|---|
|
Gateway host server should be registered on |
|
|
|
Gateway service, i.e. the port registration can be performed on |
|
|
|
The program ID registration is performed with. |
|
|
|
The number of connections that should be registered at the gateway. |
|
|
|
SAP router string to use for a system protected by a firewall. |
||
|
The maximum time (in seconds) between two startup attempts, if a failure occurs. |
||
|
Client destination from which to obtain the repository. |
||
|
Repository map, if more than one repository should be used by JCoServer. |
||
|
Enable/disable RFC trace (0 or 1). |
||
|
Set the number of threads that can be used by the JCoServer instance. |
||
|
Set the number of threads the JCoServer should always keep running. |
||
|
Secure Network Connection (SNC) mode, |
||
|
SNC level of security, 1 to 9. |
||
|
SNC name of your server. Overrides the default SNC name. Typically this is something like |
||
|
Path to library which provides SNC service. |
(*) optional parameters
(**) SNC parameters — required only if snc_mode
is ON
Server Services Configuration
If you want to receive IDocs or be called as a BAPI but do NOT want to use the PORT number as the value for jcoGwService
, then you will have to modify the Operating System services
file:
-
Unix based systems →
/etc/services
-
Windows →
C:\WINDOWS\system32\drivers\etc\services
JCo requires this configuration in order to initialize the JCo Server, which must communicate with the SAP Gateway. You can access the SAP Gateway on every application server using the TCP port You will need to add that SAP Gateway entry in the sapgw21 3321/tcp |
Complete SAP Services List
Port 3300 is predefined by SAP. If you need to validate other port numbers based on your SAP instance number, you can check the complete list of service-to-port mappings below:
Services Mappings |
---|
|
Endpoint Address
The SAP Connector supports a URI-style address to enable the use of dynamic endpoints, whose general format is:
address="sap://jcoUser:jcoPasswd@jcoAsHost?attr1=value1&attr2=value2& ... &attrN=valueN"
These attributes can be:
-
The same attributes supported in the connector or endpoint element. For example,
jcoClient
,jcoSysnr
. -
Specific SAP connection properties. For example,
jco.client.r3name
,jco.client.type
.
Whenever attributes are not specified, default values are used.
You can use Mule expressions inside the address attribute, just as you do for other Mule transports. |
Inbound Endpoint Address
<sap:inbound-endpoint
address="sap://TEST_USER:secret@localhost?type=function&rfcType=trfc&jcoClient=100&jcoSysnr=00&jcoPoolCapacity=10&jcoPeakLimit=10&jcoGwHost=localhost&jcoGwService=gw-service&jcoProgramId=program_id&jcoConnectionCount=2"/>
Clustered Environments Configuration
The SAP connector is Mule HA ready, meaning that it can work in a Mule Cluster without any issues. However, depending on the application architecture, you may need to configure your SAP endpoints accordingly.
The key to a fully working application in cluster is the implementation of reliability patterns. |
Outbound Endpoint
The outbound endpoint is usually not a problem for HA environments. If the application is correctly built to work in a cluster, then there are no special considerations. Ensure that at any given moment, only one node is processing a specific request. Typically, this is guaranteed by HA-ready inbound endpoints.
Inbound Endpoint
The inbound endpoint represents a bigger challenge when configuring your application in HA mode. The following sections provide information that will assist you in making the best decision.
SAP-Side Functionality
The SAP Connector is based on JCo Server functionality. JCo Server connects a gateway on the SAP side that is responsible for the following:
-
Load balancing requests to the SAP inbound endpoint.
-
In the case of transactional RFCs (rfcType is tRFC or qRFC), starting the transaction and making sure the same request is not sent to multiple inbound endpoints, thus avoiding duplicate requests from more than one cluster node.
Configuring the SAP Inbound Endpoint for HA
When configuring multiple SAP inbound endpoints in an HA configuration, remember that ALL nodes can share the Transaction IDs (TIDs). For this purpose, it is mandatory to configure a distributed object store-based transaction ID store. The recommended object store implementation for HA configuration is the managed-store
, since the default implementation varies depending on whether the application is running standalone or in cluster (shared object store among cluster nodes).
Also, recall that in HA configurations the payload should be serializable. To ensure this is done, configure the inbound endpoint to output XML. In Mule 3.6.0, this is easily achieved with the outputXml
attribute set to true
. In previous versions, you needed to configure a global transformer.
Mule 3.6.0 and Newer
<!-- SAP Connector -->
<sap:connector name="SapConnector"
jcoAsHost="${sap.jcoAsHost}"
jcoUser="${sap.jcoUser}"
jcoPasswd="${sap.jcoPasswd}"
jcoSysnr="${sap.jcoSysnr}"
jcoClient="${sap.jcoClient}"
jcoLang="${sap.jcoLang}"
jcoPoolCapacity="${sap.jcoPoolCapacity}"
jcoPeakLimit="${sap.jcoPeakLimit}"/>
<!-- Flow -->
<flow>
<sap:inbound-endpoint connector-ref="SapConnector"
type="function"
rfcType="trfc"
jcoGwHost="${sap.jcoGwHost}"
jcoGwService="${sap.jcoGwService}"
jcoProgramId="${sap.jcoProgramId}"
outputXml="true">
<!-- TID store -->
<sap:mule-object-store-tid-store>
<managed-store storeName="sap-tid-store" persistent="true" />
</sap:mule-object-store-tid-store>
</sap:inbound-endpoint>
<!-- Other stuff here -->
</flow>
Mule 3.4.x and before
<!-- SAP Connector -->
<sap:connector name="SapConnector"
jcoAsHost="${sap.jcoAsHost}"
jcoUser="${sap.jcoUser}"
jcoPasswd="${sap.jcoPasswd}"
jcoSysnr="${sap.jcoSysnr}"
jcoClient="${sap.jcoClient}"
jcoLang="${sap.jcoLang}"
jcoPoolCapacity="${sap.jcoPoolCapacity}"
jcoPeakLimit="${sap.jcoPeakLimit}"/>
<!-- SAP Transformer -->
<sap:object-to-xml name="sap-object-to-xml" />
<!-- Flow -->
<flow>
<sap:inbound-endpoint connector-ref="SapConnector"
type="function"
rfcType="trfc"
jcoGwHost="${sap.jcoGwHost}"
jcoGwService="${sap.jcoGwService}"
jcoProgramId="${sap.jcoProgramId}"
transformer-refs="sap-object-to-xml">
<!-- TID store -->
<sap:mule-object-store-tid-store>
<managed-store storeName="sap-tid-store" persistent="true" />
</sap:mule-object-store-tid-store>
</sap:inbound-endpoint>
<!-- Other stuff here -->
</flow>
TID Handler Configuration
The TID (Transaction ID) handler, an important component for tRFC and qRFC, ensures that Mule does not process the same transaction twice.
With the SAP connector you can configure different TID stores:
-
In Memory TID Store: the default TID store that facilitates the sharing of TIDs within the same Mule instance. If the
rfcType
is tRFC or qRFC, and no TID store is configured, then this default store is used. This is not recommended for a production environment does not work well in a clustered environment. -
Mule Object Store TID Store: this wrapper uses existing Mule object stores to store and share TIDs. If you need multiple Mule server instances, you should configure a JDBC Object Store or a cluster-enabled Object Store so that you can share TIDs between the instances.
If the rfcType is configured to srfc, or it is not provided (thus defaulting to srfc), then no TID handler is configured. Furthermore, if a TID handler has been configured in the XML file, it will be ignored.
|
Default In-memory TID Store
To configure an in-memory TID Store successfully, you must understand the following:
-
The in-memory TID Store does NOT work as expected if you have multiple Mule instances that share the same
program ID
. This happens because the SAP gateway balances the load across all registered SAP servers that share the sameprogram ID
. -
The
rfcType
in the<sap:inbound-endpoint />
should be trfc or qrfc. -
Configuring the child element
<sap:default-in-memory-tid-store />
is optional, since the in-memory handler is set by default.<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:sap="http://www.mulesoft.org/schema/mule/sap" 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/sap http://www.mulesoft.org/schema/mule/sap/current/mule-sap.xsd http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd"> <!-- Credentials --> <context:property-placeholder location="sap.properties"/> <!-- SAP Connector --> <sap:connector name="SapConnector" jcoClient="${sap.jcoClient}" jcoUser="${sap.jcoUser}" jcoPasswd="${sap.jcoPasswd}" jcoLang="${sap.jcoLang}" jcoAsHost="${sap.jcoAsHost}" jcoSysnr="${sap.jcoSysnr}" jcoTrace="${sap.jcoTrace}" jcoPoolCapacity="${sap.jcoPoolCapacity}" jcoPeakLimit="${sap.jcoPeakLimit}"/> <!-- Flow --> <flow name="idocServerFlow"> <sap:inbound-endpoint name="idocServer" exchange-pattern="request-response" type="idoc" rfcType="trfc" jcoGwHost="${sap.jcoGwHost}" jcoProgramId="${sap.jcoProgramId}" jcoGwService="${sap.jcoGwService}" jcoConnectionCount="${sap.jcoConnectionCount}"> <!-- TID --> <sap:default-in-memory-tid-store/> </sap:inbound-endpoint> <!-- Other stuff here --> </flow> </mule>
JDBC-based Mule Object Store TID Store
To configure the Mule Object Store TID Store, complete the following steps:
-
Configure the
rfcType
in the<sap:inbound-endpoint />
component astrfc
orqrfc
. -
Configure the child element
<sap:mule-object-store-tid-store>.
-
Configure a DataSource bean with Database Connection details.
-
Configure a JDBC connector.
The child element of <sap:mule-object-store-tid-store> can be any of the supported Mule Object Stores.
|
This example illustrates how to configure a MySQL-based JDBC object store.
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:sap="http://www.mulesoft.org/schema/mule/sap"
xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc"
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/sap http://www.mulesoft.org/schema/mule/sap/current/mule-sap.xsd
http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/current/mule-jdbc.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd">
<!-- Credentials -->
<context:property-placeholder location="sap.properties"/>
<!-- JDBC configuration -->
<spring:bean id="jdbcProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<spring:property name="location" value="classpath:jdbc.properties"/>
</spring:bean>
<!-- TID Store configuration -->
<spring:bean id="jdbcDataSource"
class="org.enhydra.jdbc.standard.StandardDataSource"
destroy-method="shutdown">
<spring:property name="driverName" value="${database.driver}"/>
<spring:property name="url" value="${database.connection}"/>
</spring:bean>
<!-- JDBC Connector -->
<jdbc:connector name="jdbcConnector" dataSource-ref="jdbcDataSource" queryTimeout="${database.query_timeout}">
<jdbc:query key="insertTID" value="insert into saptids (tid, context) values (?, ?)"/>
<jdbc:query key="selectTID" value="select tid, context from saptids where tid=?"/>
<jdbc:query key="deleteTID" value="delete from saptids where tid=?"/>
</jdbc:connector>
<!-- SAP Connector -->
<sap:connector name="SapConnector"
jcoClient="${sap.jcoClient}"
jcoUser="${sap.jcoUser}"
jcoPasswd="${sap.jcoPasswd}"
jcoLang="${sap.jcoLang}"
jcoAsHost="${sap.jcoAsHost}"
jcoSysnr="${sap.jcoSysnr}"
jcoTrace="${sap.jcoTrace}"
jcoPoolCapacity="${sap.jcoPoolCapacity}"
jcoPeakLimit="${sap.jcoPeakLimit}"/>
<!-- Flow -->
<flow name="idocServerFlow">
<sap:inbound-endpoint name="idocServer"
exchange-pattern="request-response"
type="idoc"
rfcType="trfc"
jcoGwHost="${sap.jcoGwHost}"
jcoProgramId="${sap.jcoProgramId}"
jcoGwService="${sap.jcoGwService}"
jcoConnectionCount="${sap.jcoConnectionCount}">
<!-- TID -->
<sap:mule-object-store-tid-store>
<jdbc:object-store name="jdbcObjectStore"
jdbcConnector-ref="jdbcConnector"
insertQueryKey="insertTID"
selectQueryKey="selectTID"
deleteQueryKey="deleteTID"/>
</sap:mule-object-store-tid-store>
</sap:inbound-endpoint>
<!-- Other stuff here -->
</flow>
</mule>
Make sure to note the following points:
|
Database Creation Script for the JDBC Object Store
-- MySQL Script
CREATE DATABASE saptid_db;
GRANT ALL ON saptid_db.* TO 'sap'@'localhost' IDENTIFIED BY 'secret';
GRANT ALL ON saptid_db.* TO 'sap'@'%' IDENTIFIED BY 'secret';
USE saptid_db;
CREATE TABLE saptids
(
tid VARCHAR(512) PRIMARY KEY,
context TEXT
);
Retrieve TID Using a MEL Expression
When sending or retrieving IDocs, depending on the use case you may be required to obtain the IDoc number. Since the interchange of IDocs is inherently asynchronous, the only information that SAP and Mule share is the Transaction IDs.
The Transaction ID has been added as a new property to the Mule Message to satisfy the requirement that a Transaction ID be provided to get an IDoc number. This enhancement allows the customer to call RFC-enabled Function Modules on SAP in order to retrieve the IDoc number. These RFC-enabled Function Modules are:
-
INBOUND_IDOCS_FOR_TID
-
OUTBOUND_IDOCS_FOR_TID
Use the following MEL expression to extract the value of the TID:
#[message.outboundProperties.sapTid]
Below are two simple examples for inbound and outbound calls:
<!-- INBOUND | Receive IDoc -->
<sap:inbound-endpoint type="idoc" rfcType="trfc" outputXml="true"
jcoGwHost="${sap.jcoGwHost}" jcoProgramId="${sap.jcoProgramId}"
jcoGwService="${sap.jcoGwService}" jcoConnectionCount="${sap.jcoConnectionCount}" ...>
<!-- transaction config -->
<sap:mule-object-store-tid-store>
<jdbc:object-store name="jdbcObjectStore" ... />
</sap:mule-object-store-tid-store>
</sap:inbound-endpoint>
<logger message="#[message.outboundProperties.sapTid]" level="INFO" doc:name="Logger"/>
<!-- OUTBOUND | Send IDoc -->
<sap:outbound-endpoint type="idoc" rfcType="trfc" outputXml="true" ...>
<!-- transaction config -->
<sap:transaction action="BEGIN_OR_JOIN"/>
</sap:outbound-endpoint>
<logger message="#[message.outboundProperties.sapTid]" level="INFO" doc:name="Logger"/>
The TID feature is only available since SAP Connector 2.2.8. |
Transactions
The SAP Connector does not support distributed transactions because JCo does not support XA. However, the SAP outbound endpoint supports the child element transaction:
<sap:transaction action="ALWAYS_BEGIN" bapiTransaction="true|false"/>
Compatibility Notes Transaction support in the SAP Connector version 1.x is very limited and only transactions of one function call are allowed. Starting with the SAP Connector version 2.1.0, the attribute |
Attribute | Description | Default Value | Since Version |
---|---|---|---|
action |
The action attribute is part of the Mule transaction standard and can have the following values: |
|
|
bapiTransaction |
When set to |
|
|
For more information, consult the Transactions Configuration Reference. |
Combining the RFC type (rfcType) attribute defined in the outbound endpoint with the transaction facilitates different ways for the SAP connector to handle the transaction.
If a transaction is not specified, then all calls (execute function or send IDoc) are stateless. |
sRFC Stateful
All calls are done using synchronous RFC as the connector and share the same context.
Configuration
<sap:outbound-endpoint
exchange-pattern="request-response"
type="function"
bapiTransaction="false"
rfcType="srfc" ... >
<sap:transaction
action="NONE | ALWAYS_BEGIN | BEGIN_OR_JOIN | ALWAYS_JOIN | JOIN_IF_POSSIBLE" />
</sap:outbound-endpoint>
Stateful calls are used to call more than one BAPI using the same context. If the execution of these BAPI calls takes place in the same thread, then this is equivalent in JCo to:
JCoContext.begin(destination);
function1.execute(destination);
function2.execute(destination);
function3.execute(destination);
JCoContext.end(destination);
sRFC Stateful BAPI Transaction
All calls are done using synchronous RFC as the connector and share the same context and the BAPI_TRANSACTION_COMMIT
is called at the end of the transaction.
Configuration
<sap:outbound-endpoint
exchange-pattern="request-response"
type="function"
bapiTransaction="true"
rfcType="srfc" ... >
<sap:transaction
action="NONE | ALWAYS_BEGIN | BEGIN_OR_JOIN | ALWAYS_JOIN | JOIN_IF_POSSIBLE" />
</sap:outbound-endpoint>
If the BAPIs that are called change values in SAP tables, then a call to a special BAPI is required: For this to work, the whole unit of work must be in the same thread and the calls need to be stateful. |
The Java JCo code that calls these "special" BAPIs is as follows:
commitFunction = createJCoFunction("BAPI_TRANSACTION_COMMIT");
rollbackFunction = createJCoFunction("BAPI_TRANSACTION_ROLLBACK");
try
{
JCoContext.begin(destination);
function1.execute(destination);
function2.execute(destination);
commitFunction.execute(destination);
}
catch(Exception ex)
{
rollbackFunction.execute(destination);
}
finally
{
JCoContext.end(destination);
}
tRFC Stateful
All calls are done using transactional RFC as the connector and share the same context.
Configuration
<sap:outbound-endpoint
exchange-pattern="request-response"
type="function"
bapiTransaction="false"
rfcType="trfc" ... >
<sap:transaction
action="NONE | ALWAYS_BEGIN | BEGIN_OR_JOIN | ALWAYS_JOIN | JOIN_IF_POSSIBLE" />
</sap:outbound-endpoint>
The JCo code to invoke BAPIs through tRFC looks like this:
String tid = destination.createTID();
try
{
JCoContext.begin(destination, tid);
function1.execute(destination, tid);
function2.execute(destination, tid);
}
finally
{
JCoContext.end(destination);
}
qRFC Stateful
All calls are done using queued RFC as the connector and share the same context.
Configuration
<sap:outbound-endpoint
exchange-pattern="request-response"
type="function"
rfcType="qrfc"
queueName="QUEUE_NAME" ... >
<sap:transaction
action="NONE | ALWAYS_BEGIN | BEGIN_OR_JOIN | ALWAYS_JOIN | JOIN_IF_POSSIBLE"
bapiTransaction="false"/>
</sap:outbound-endpoint>
To invoke BAPIs through qRFC, you need to provide a value for the attribute queueName
. The JCo code to implement this is:
String tid = destination.createTID();
try
{
JCoContext.begin(destination, tid);
function1.execute(destination, tid, queueName1);
function2.execute(destination, tid, queueName2);
}
finally
{
JCoContext.end(destination);
}
Example
The following example only works in Mule 3.3+ with SAP Connector version 2.1.0 or greater. It describes how to execute two BAPIs in a stateful transaction.
<mule ...>
<!-- SAP credentials -->
<!-- SAP Connector configuration -->
<flow>
<!-- Other components -->
<sap:xml-to-object/>
<!-- Transaction -->
<transactional>
<!-- BAPI call 1 -->
<sap:outbound-endpoint
exchange-pattern="request-response"
type="function"
bapiTransaction="true"
rfcType="srfc"
functionName="BAPI-1" ... >
<sap:transaction action="ALWAYS_BEGIN"/>
</sap:outbound-endpoint>
<!-- Other components -->
<sap:xml-to-object/>
<!-- BAPI call 2 -->
<sap:outbound-endpoint
exchange-pattern="request-response"
type="function"
bapiTransaction="true"
rfcType="srfc"
functionName="BAPI-2" ... >
<sap:transaction action="BEGIN_OR_JOIN"/>
</sap:outbound-endpoint>
</transactional>
<!-- Other components -->
</flow>
</mule>
See Also
-
SAP Connector Troubleshooting to handle common problems.