Skip to Content
Former Member
Aug 12, 2010 at 09:30 AM

deadlock in formdata_add event after save as draft and recordset by ODRF



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
                        '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)
                        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