Using DI API Global Transactions
When a data operation is performed on a business object, a transaction is started. If the operation is successful, then a Commit is issued and the data is saved. If the operation fails, then a Rollback is issued and the data is discarded.
This kind of transaction handling is sufficient as long as only one business object is being modified.
If you want to perform a consistent transaction that contains changes to more than one business object, Global Transaction is used. You must specify the start and end of the transaction using the company object methods StartTransaction and EndTransaction.
In other words, a Global Transaction is a logical unit of work in which:
- All operations are either successful or unsuccessful.
- Operations are performed that correctly transform data from one consistent state to another.
When GLOBAL TRANSACTIONS are used, the database isolation levels are maintained at the highest level. This means all the resources (tables, indexes, views etc.) will have exclusive locks and will be blocked for any operation by other transactions.
Use this method to start a Global Transaction that can contain multiple changes to several business objects.
When you call StartTransaction, all business object changes that are issued after this call and before a following call to the method EndTransaction, belong to one logical unit of operation.
If one of the business object changes fails during any process, the transaction ends and a rollback is issued automatically.
Use this method to end the Global Transaction started by StartTransaction method.
You must pass a parameter to EndTransaction (endType as SAPBobsCom.BoWfTransOpt) to indicate whether the changes contained within this transaction are to be committed or rolled back.
- When one of the user uses GLOBAL TRANSACTION, other user using SAP Business One System forms or add-on forms freezes.
- When one of the user uses GLOBAL TRANSACTION, login to Business One Application might become slow.
- Business One application users and Add-on application might crash or transaction end with error code -2038,-2039 or -5002
- Using transactions can also increase the number and extent of locks (or other isolation mechanism, depending on the database) used in the system, which can lead to concurrency issues.
- Every StartTransaction should be completed with the EndTransaction method.
- Use the GLOBAL TRANSACTIONS only for short duration transactions with less concurrency.
- If you are running complex time consuming logic, please schedule such activity on productive hours.
- Make sure logic involving GLOBAL TRANSACTIONS does not wait for user inputs.
- Do not use multithreaded programing with GLOBAL TRANSACTION, this will lead to data inconsistency. Be aware that DI API does not support multithreading.
- Employ retry mechanism in case of deadlock errorcode – 2038. Refer to SAP Note 1444532 for the same.
I remember I read somewhere that DI API Since version 9.1/9.2 (I can't remember which exact version also) is already thread aware ?
Can you confirm on this?
The functionality was planned however it never happened and delivered.
We only support 1 thread in 1 process to access DI COM interface officially.
SAP SME Support
so DI com cant use StartTransaction right?
i have 10 record....when 4th data got error ,before 3 will commit and direct stop all transaction
Hi s wk,
I am not able to understand your question.
To let you know, if you will get the error, all processes within the transaction will be rolled back.
SAP SME Support
I see that this problem was reporter since 2010..
There is any solutions or Workaround?