cancel
Showing results for 
Search instead for 
Did you mean: 

SAP freezing due to SQL lock under transaction

leandro_daminelli2
Participant
0 Kudos

Hello everyone.

Our addon have a form which contains a "Finish" button that can be used when the form is in ADD or UPDATE mode. When the user clicks on it, the addon creates some documents. I did it under a transaction because it's more than one document, so I must ensure that all of them or nothing will be created.

The thing is, sometimes when the "Finish" routine is done succesfully, SAP wont let the user add or update the register because of closed period or any other issue, so I have a few documents created by my form but the data was not added/updated on the database. If the user tries again, it will create the documents again and again..

To solve this issue I've changed the code to end the transaction on After Form Add/Update event. When the ActionSuccess is true, I commit the transaction, if it's false then I rollback. The problem is that I have created another issue. Sometimes it works fine, but sometimes SAP freezes after clicking on Add/Update button.

I did some tests in the database and the issue seems to be ONNM table that gets locked.

Any toughts?

Accepted Solutions (0)

Answers (1)

Answers (1)

edy_simon
Active Contributor
0 Kudos

Hi Leandro,

I would move the document creation to the After form data add/Update event.

I would make sure my form data is created in the database, and after that, I will try to create the documents, commit and rollback as necessary.

This way :

1, If data created + Document created -> no issue.

2. If data not created -> Document will not be created.

3. If data created + Document not created -> user can rectify the problem (ie. Opening the closed period) and re-do the document creation by updating the form.

Of course there is a draw back also, On point 3, SAP will always shows up a message operation completed + another message of your addon.

The safest way to handle this,

I would set my form to not auto managed. (This mean you will loose automatic DB update/add for your form)

On the before item pressed event, I would :

1. Start Transaction.

2. Create/Update my form data to DB.

3. Create documents.

4. If 2 & 3 success, commit, else roll back. BubbleEvent = true or false depending on the result.

The correct way to handle this : if you are using UDO, use the DLL to create the additional documents.

Regards
Edy

leandro_daminelli2
Participant
0 Kudos

Hi Edy, thank you in advice.

But this statement is really nonsense for me because if I'm under a transaction, all I need to do is to use Recordset to prevent SQL locks. Why SBO does not use it the same way?

It's really hard for me to manage this because when the user hits my "Finish" button I set some flags and fields in the main table through the DataSource, so if I create my documents on after form data add event then I'll need somehow to undo this flags/fields.


This is annoying because for each solution that I code, SBO creates another issue.