Skip to Content
0
Former Member
Jul 19, 2011 at 08:24 AM

Connect company in SAP 8.81

76 Views

I am using SAP 8.81.I am using the following code to connect to company -

Public Function ConnectToCompany()
        Dim strCookie As String
        Dim strConnection As String

        Try
            MessageBox.Show("Start ConnectToCompany")
            *objCompany = New SAPbobsCOM.Company*
            MessageBox.Show(1)
            strCookie = objCompany.GetContextCookie
            MessageBox.Show(2)
            strConnection = SBO_Application.Company.GetConnectionContext(strCookie)
            MessageBox.Show(3)
            objCompany.DbServerType = BoDataServerTypes.dst_MSSQL2008
            MessageBox.Show(4)
            objCompany.SetSboLoginContext(strConnection)
            MessageBox.Show(5)
            objCompany.Connect()
            MessageBox.Show(6)
            If objCompany.GetLastErrorDescription.Length > 0 Then
                SBO_Application.MessageBox(objCompany.GetLastErrorDescription)
            Else
                If SBO_Application.Desktop.Title.Contains("2005") Then
                    strFormType = "390"
                    strControl = "141"
                    dblCount = 117
                    strSeries = "JV/R"
                ElseIf SBO_Application.Desktop.Title.Contains("8.8") Then
                    MessageBox.Show(7)
                    strFormType = "392"
                    strControl = "137"
                    dblCount = 140
                    strSeries = "JV/R"
                End If
                MessageBox.Show(8)
                GetAuthentication()
                MessageBox.Show(9)
            End If
            MessageBox.Show("End ConnectToCompany")
        Catch ex As Exception
            SBO_Application.MessageBox("Tour Reporter:ConnectToCompany()=" & ex.Message)
        End Try
    End Function

I have used message boxes to tracking the flow of the code.The message "Start ConnectToCompany " fires.After this message does not appear. The execution stops at the statement,

objCompany = New SAPbobsCOM.Company