cancel
Showing results for 
Search instead for 
Did you mean: 

Rollback / Commit in JCO

Former Member
0 Kudos

Hi,

I would like to know how transaction management can be done from JCO. How do I Rollback transactions from JCO??

In Java

{

//Execute RFC through JCO Call(Creates DB record in R/3)

//Face exception here

//I need to roll back the RFC ????

}

Thanking You,

Guru

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Guru,

I think you are performing a process through a Transaction Id (or without it) with the help of a remote enabled function module(RFM). All these changes will not be reflected in DB unless it is committed. Hence after performing the required task through a RFM you can commit it ot rollback it. This commit/rollback will affect for the transaction performed immediately before it. Hence there will not be any problem i suppose (as far as i have known).

Thanks & Regards

Kathirvel

Former Member
0 Kudos

Hello,

what about doing a commit before you start doing anything to create a starting point for the transaction and then do a commit/rollback when you are done? Some colleague who does SAP told me that SAP people often do it this way.

Regards, Oliver Plohmann

Former Member
0 Kudos

Hi Guru,

http://66.102.7.104/search?q=cache:YnarUK_KhHcJ:www.tnatum.com/SAP/SAPPJ/Vol%25202/Issue%25203/p025....rollbackspecifictransactionsidsusingBAPI_TRANSACTION_ROLLBACK&hl=en

Check this out.

Regards,

Kathirvel

guru_subramanianb
Active Contributor
0 Kudos

Hi Guru,

By default auto commit property is set to be false.whn you want to set is then you have explicitly set it to true.

rdgs,

guru

Former Member
0 Kudos

Hi,

I checked the BAPIs BAPI_TRANSACTION_ROLLBACK and BAPI_TRANSACTION_COMMIT. But these transactions do not take transaction ID as a prameter. So how do I associate the BAPI call with the transaction?

Regards,

Guru

Former Member
0 Kudos

Hi Guru,

Yes you approach is correct, make sure commit/rollback is possible only when a change is/was made in database.

Go through these links will be helpful,

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/d352a790-0201...

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/d352a790-0201...

Hope that solves your problem.

Thanks & Regards,

Kathirvel

Former Member
0 Kudos

>> make sure commit/rollback is possible only when a change is/was made in database

What would be wrong with calling a commit/rollback if no database changes have been made?

I've got a generic framework and have no idea if the BAPIs that are being called will update the database or not. So I always call commit.

TIA

Ian

Former Member
0 Kudos

Hi Kathirvel,

Thanks for the links. All this is fine but how do I know if autocommit is true or not?? In other words, how do I disable the auto commit property from JCO??

Regards,

guru

Former Member
0 Kudos

Hi Guru,

Welcome to SDN.

Use BAPI_TRANSACTION_COMMIT to commit changes to DB after any operation. Use BAPI_TRANSACTION_ROLLBACK to roll back.

Cheers

Kathirvel

Former Member
0 Kudos

Hi Karthivel,

Thanks for ur reply!

I would like to know if my approach is correct....

1. I create a TId (transaction ID)

2. I execute RFCs using this TId

3. I use BAPI_TRANSACTION_COMMIT(TId) to commit (or)

4. I use BAPI_TRANSACTION_ROLLBACK(TId) to rollback

Regards,

Guru