cancel
Showing results for 
Search instead for 
Did you mean: 

JCO and stateful calls

Former Member
0 Kudos

Hi,

I need to call many RFC's and at the end commit (or rollback) the updated data, like they belong to the same transaction.

I tried two approaches:

- Using com.sap.conn.jco.JCoDestination::createTID and com.sap.conn.jco.JCoDestination::confirmTID after the function is executed;

- Using com.sap.conn.jco.JCoContext::begin, execute the function and com.sap.conn.jco.JCoContext::end;

But with both approaches the data is commited just after the RFC is executed.

There is no commit work in the functions (all Z functions).

Is there some autocommit option in JCO?

I'm using JCO version 3.

Regards

Michel

Accepted Solutions (1)

Accepted Solutions (1)

ravindra_bollapalli2
Active Contributor
0 Kudos

hi,

i hope so (not sure)

check this

http://help.sap.com/saphelp_mii121/helpdata/en/45/0ee04bcd214030e10000000a1553f6/content.htm

at end of the html page u can find the "autocommit" -- boolean we have to set

let me know am i correct or wrong

bvr

Former Member
0 Kudos

Hi bvr,

I saw this already.

Anyway, I called JCo.setProperty("AutoCommit", false) before anything, but it does not work.

I will open a note for SAP. It looks like a bug or something.

Thanks for the answer!

Michel

0 Kudos

hi Michel

how can i call JCo.setProperty("AutoCommit", false) in JCo3.0 ?

thanks

basis

Answers (1)

Answers (1)

HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Michel,

JCo doesn't have an AutoCommit feature.

This is the relevant part from the JCo documentation:

Class com.sap.conn.jco.JCoContext

The JCoContext class allows the execution of stateful function call sequences
with JCo. It provides methods for notifying the JCo runtime about starting and
ending stateful call sequences for a specific destination. The same connection
will be used for all remote function calls between invoking the start() and
end() methods. This is typically used for multi-step logical units of work
(LUWs), in which several function modules are executed in a row and are
committed afterwards.
In case an error occurs during the communication and
the connection is broken or closed, an exception will be thrown and the
application should take care of this. Depending on the application it might be
necessary to repeat all function calls of the failed sequence as the back-end
will do an automatic rollback of all previous operations that have not been
committed yet.

    JCoDestination destination = JCoDestinationManager.getDestination("<DestinationName>");

    try

    {

        JCoContext.begin(destination);

        function1.execute(destination);

        function2.execute(destination);

        funcBapiTransactionCommit.execute(destination);

    }

    catch (AbapException ex)

    {

        ...

    }

    catch (JCoException ex)

    {

        ...

    }

    catch (Exception ex)

    {

        ...

    }

    finally

    {

        JCoContext.end(destination);

    }

Internally, the JCo runtime considers all calls executed in the

current session and scope between begin() and end() as coherent and sends the

calls over the same connection. Stateful contexts can be nested. The respective

connection will be released only after the root context is ended, i.e. end()

needs to be called as many times as begin() was called before for a specific

destination.

Applications or application environments, that can change the

thread during a stateful call sequence, have to provide and register a custom

implementation of the SessionReferenceProvider for supporting such a feature.

The default implementation does not support stateful call sequences across

several threads.


--------------------

If data is already persisted / committed without calling BAPI_TRANSACTION_COMMIT as the final remote function of your call sequence, then this step is already done in your ABAP Z-function module(s) or within the ABAP code that they are calling internally.

Best regards,

Stefan