Skip to Content
1
Oct 29, 2014 at 12:52 PM

Atomicity while adding records on User Forms using UDO

74 Views

Dear SAP B1 Developers,

In many forms of our Add-on we have to add records in other user tables and/or system tables, in a trigger like manner.

To accomplish that, we currently use the OnBeforeFormDataAdd event of our user defined forms. However that are cases when we need the DocEntry of the record being added to update a record in another table. In those cases we use the OnAfterFormDataAdd event.

As a result, this way we can't guarantee atomicity. We have tried some solutions:

  1. Starting a transaction on the OnBeforeFormDataAdd event and ending it on the OnAfterFormDataAdd event.
    • Issue: as part of the process on OnBeforeFormDataAdd event creates a record in some table, the ONNM table gets locked, so the record being added fails on insert phase (Between OnBeforeFormDataAdd and OnAfterFormDataAdd events)
  2. Doing all the process on the OnBeforeFormDataAdd event and setting bubble event to false:
    • Issue: It works fine. We add the record of the form through DIAPI. The only thing is that SAP B1 returns a message indicating that the process has been canceled by the user, so we set another message (green one) signaling that the process has succeeded. Not good to see.
  3. Using UDO DLL implementation:
  • Issue: we have started our tests with this solution. Our idea is similar to the previous one, but with the proper message at the end of the process. For this, we thought about removing the line that does the insert in the OnAdd() method of the dll and only return 0 to indicate the process have completed successfully. Hence all the implementation would be done during the OnBeforeFormDataAdd event.

What do you guys think? Any suggestion?

Thanks!