cancel
Showing results for 
Search instead for 
Did you mean: 

Disconnect AddOn

dilipkumbhar
Participant
0 Kudos
321

I am using SAP B1 9.2 PL:08. I have developed Validation add-on which gets disconnected after some time. I can not predict the condition when it gets disconnected . I have used these codes for connecting UI API and DI API. Please see the below code and tell me if there is some problem in my code.


'First I connect UI API.
Public Sub SetApplication()
        Dim SboGuiApi As SAPbouiCOM.SboGuiApi
        Dim sConnectionString As String
        Try
            SboGuiApi = New SAPbouiCOM.SboGuiApi
            sConnectionString = Environment.GetCommandLineArgs.GetValue(1)
            SboGuiApi.Connect(sConnectionString)
            SBO_Application = SboGuiApi.GetApplication()
        Catch ex As Exception
            WriteLog(SBO_Application.Company.ServerDate & ":" & SBO_Application.Company.ServerTime & ":" & "SetApplication()=" & ex.Message & vbNewLine & "Line=" & ex.StackTrace)
        End Try
    End Sub
'Then I connect DI API.
Public Sub ConnectToCompany()
        Dim objProcess As Process

        Try
            objCompany = New SAPbobsCOM.Company
            objCompany = SBO_Application.Company.GetDICompany
            If objCompany.GetLastErrorDescription.Length > 0 Then
                SBO_Application.MessageBox(objCompany.GetLastErrorDescription)      
           End If
        Catch ex As Exception
            WriteLog(SBO_Application.Company.ServerDate & ":" & SBO_Application.Company.ServerTime & ":" & "ConnectToCompany()=" & ex.Message & vbNewLine & "Line=" & ex.StackTrace)          
      End Try
End Sub

Accepted Solutions (0)

Answers (0)