Skip to Content

Definition:

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:

  1. All operations are either successful or unsuccessful.
  2. 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.

StartTransaction:

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.

EndTransaction:

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.

Common Issues:

  1. When one of the user uses GLOBAL TRANSACTION, other user using SAP Business One System forms or add-on forms freezes.
  2. When one of the user uses GLOBAL TRANSACTION, login to Business One Application might become slow.
  3. Business One application users and Add-on application might crash or transaction end with error code -2038,-2039 or -5002
  4. 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.

Recommendations:

  1. Every StartTransaction should be completed with the EndTransaction method.
  2. Use the GLOBAL TRANSACTIONS only for short duration transactions with less concurrency.
  3. If you are running complex time consuming logic, please schedule such activity on productive hours.
  4. Make sure logic involving GLOBAL TRANSACTIONS does not wait for user inputs.
  5. Do not use multithreaded programing with GLOBAL TRANSACTION, this will lead to data inconsistency. Be aware DIAPI does not support multithreading.
  6. Employ retry mechanism in case of deadlock errorcode – 2038. Refer to SAP Note 1444532 for the same.
To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

  1. Edy Simon

    Hi Ankit,

    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?

    Regards
    Edy

    (1) 
  2. ANKIT CHAUHAN Post author

    Hi Edy,

    The functionality was planned however it never happened and delivered.

    We only support 1 thread in 1 process to access DI COM interface officially.

     

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

    (1) 
    1. s wk

      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

      (0) 
  3. ANKIT CHAUHAN Post author

    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.

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

     

    (1) 

Leave a Reply