on 08-12-2010 10:30 AM
hi,
i'm using the form data add event with actionsuccess=false to save invoice as draft.
After saving the document as draft and do a query in table odrf there will be deadlock.
The deadlock is shown in sql server. I have to kill this process in the activity monitor of the sql server to go on in business one.
Private Sub moSBOApplication_FormDataEvent(ByRef BusinessObjectInfo As SAPbouiCOM.BusinessObjectInfo, ByRef BubbleEvent As Boolean) Handles moSBOApplication.FormDataEvent
'only invoice are allowed
If BusinessObjectInfo.FormTypeEx <> "133" Then Exit Sub
'no draft allowed.
If BusinessObjectInfo.Type = "112" Then Exit Sub
Select Case BusinessObjectInfo.EventType
Case SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD
Select Case BusinessObjectInfo.ActionSuccess
'before invoice is added
Case False
'set id in textbox comment
moSBOApplication.Forms.ActiveForm.Items.Item("16").Specific.value = "$99$"
'save as draft
moSBOApplication.ActivateMenuItem("5907")
'fetch draft docentry
Dim iDraftDocentry As Integer = 0
Dim oRec As SAPbobsCOM.Recordset = moSBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
Dim sSql As String = "SELECT isnull(docentry,0) as docentry " _
& " FROM ODRF " _
& " WHERE ObjType =13 " _
& " and charindex('$99$',comments)>0"
oRec.DoQuery(sSql) ' <-- after executing this line there is a deadlock in database. If i use another table than odrf it would be all right. The odrf is locked.
While oRec.EoF = False
iDraftDocentry = CInt(oRec.Fields.Item("docentry").Value)
oRec.MoveNext()
End While
'publish draft docentry
moSBOApplication.MessageBox("" & iDraftDocentry)
End Select
End Select
End Sub
SAP Version: 8.8 PL13
Does anybody know how to prevent the deadlock? Or is this a bug?
best regards
Markus
Hello
Deadlock reason: You are in transaction, and until the transaction is alive, you cannot query against the table.
Please revise your code, and check where you starting transactions.....
Regards
János
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Janos,
i don't use transactions. As you can see in my code the only transaction is the system transaction of the formdata add event.
I also tried to set the bubbleevent=false but that doesn't matter.
I have an invoice in add mode and after pressing the add button the formdata event is done. There are no other transactions.
Any idea?
best regards
Markus
Hi Markus,
The SBO client is most likely using a SQL transaction when it is saving the document as a draft so your code does indirectly make use of a transaction. You might be able to get around this issue by calling Application.DoEvents after you activate the Save As Draft menu. If that doesn't work then I think you would need to put your code in a different event (maybe moving the DoQuery part to the BeforeAction=false section of the FormDataAdd event would do the trick).
Kind Regards,
Owen
User | Count |
---|---|
101 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.