Contact Us 1-800-596-4880

Outbound Endpoint Transactions

Mule runtime engine version 3.8 reached its End of Life on November 16, 2021. For more information, contact your Customer Success Manager to determine how to migrate to the latest Mule version.

This page lists the outbound endpoint transactions of the SAP Connector.

sRFC stateful

All calls are done using synchronous RFC as transport and sharing the same context.

Configuration Examples

Version 1.x

<sap:outbound-endpoint
    exchange-pattern="request-response"
    type="function"
    rfcType="srfc" ...>

    <sap:transaction action="NONE | ALWAYS_BEGIN | BEGIN_OR_JOIN | ALWAYS_JOIN | JOIN_IF_POSSIBLE" bapiTransaction="false"/>

</sap:outbound-endpoint>

Version 2.x+

<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 in SAP using the same context. If the execution of calling these BAPIs take 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 transport and sharing the same context and the BAPI_TRANSACTION_COMMIT is called at the end.

Configuration Examples

Version 1.x

<sap:outbound-endpoint
    exchange-pattern="request-response"
    type="function"
    rfcType="srfc" ...>

    <sap:transaction action="NONE | ALWAYS_BEGIN | BEGIN_OR_JOIN | ALWAYS_JOIN | JOIN_IF_POSSIBLE" bapiTransaction="true"/>

</sap:outbound-endpoint>

Version 2.x+

<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: BAPI_TRANSACTION_COMMIT or BAPI_TRANSACTION_ROLLBACK. For this to work, the whole unit of work needs to be in the same Thread and the calls need to be stateful.
The JCo code to implement this is:

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 transport and sharing the same context.

Configuration Examples

Version 1.x

<sap:outbound-endpoint
    exchange-pattern="request-response"
    type="function"
    rfcType="trfc" ...>

    <sap:transaction action="NONE | ALWAYS_BEGIN | BEGIN_OR_JOIN | ALWAYS_JOIN | JOIN_IF_POSSIBLE" bapiTransaction="false"/>

</sap:outbound-endpoint>

Version 2.x+

<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.creatTID();
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 transport and sharing 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.creatTID();
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 shows how to execute 2 BAPIs in a stateful transaction.

<mule ...>

    <flow>
        ...
        <sap:xml-to-object/>
        <transactional>
            <sap:outbound-endpoint exchange-pattern="request-response" type="function"
                                   bapiTransaction="true" rfcType="srfc" functionName="BAPI-1" ...>
                <sap:transaction action="ALWAYS_BEGIN"/>
            </sap:outbound-endpoint>
            ...
            <sap:xml-to-object/>
            <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>
        ...
    </flow>
</mule>