on 10-17-2004 2:53 PM
Hi all
Anyone who have had the problem running two addons on the same client... I've have some problems with the connections (It a bit random, but most often one of the addon keeps running while the other fails due to some problems connection to the DI company (Single-sigon)).. The work perfectly apart, but together this happens... Any hint to why that migth be...
Hi Rasmus,
we had a similar problem with two parts of the same program opening a connection to DiApi at the same time.
If you can, ensure that both addons have their time to connect to DiApi. (Maybe letting a process sleep for a while). SAP Business One really should take care of this issue (and does most of the time).
HTH, Lutz Morrien
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Lutz... I'we come to the same conclusion, and letting the process sleep for a second "solves" the problem (Threading.Thread.sleep(1000);)
As I see the problem it must be about threads that don't finish before other threads take over and there for is in the middle of a connection call via the SDK... This other thread also calls the SDK connection and fails for some reason.
Perhaps make the call to the connect-method treadsafe(Transaction of some sort) will help the problem, but I've havent yet had the time to test this... (I'll post the result when I have the time)
Anyone from SAP inhere care to comment on this issue?
I have noticed the same issue upon installation of the most recent 6.5 patch. I spent an hour or so frustrated by it last night.
It seems that the second add on that is loaded is unable to connect to the database using the login context provided by the UI, at least on the first attempt.
I did not notice this in any previous patch. Can anybody corroborate that this was in fact introduced in the current patch?
In any event, I've modified my Setup function to allow for this, and all my add ons are playing nicely again.
Here it is, just in case it saves anybody some time.
Private Sub Class_Initialize()
Dim TmpApp As SAPbouiCOM.Application
'
' It seems that withevents variables can't be passed by ref, so I am passing in a temporary application var.
'
Call SetupApplication(TmpApp, mCompany)
Set mApplication = TmpApp
Call SetFilters
Call AddMenuItems(mApplication)
End Sub
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Function SetupApplication(ByRef Application As SAPbouiCOM.Application, ByRef Company As SAPbobsCOM.Company) As Boolean
On Error GoTo ErrorTrap
Dim SboGuiApi As SAPbouiCOM.SboGuiApi
Dim sConnectionString As String
Dim ReturnCode As Integer
Dim ErrorCode As Long
Dim ErrorMessage As String
Dim RS As SAPbobsCOM.Recordset
Dim ReturnValue As Boolean
Dim Cookie As String
Dim ConnectionContext As String
Dim Counter As Long
'
' until found to be true
'
ReturnValue = False
'
' Only get the application object once. On company change events, this function will be called again, so it will
' reuse the same application object, but connect to a new DB.
'
If Application Is Nothing Then
Set SboGuiApi = New SAPbouiCOM.SboGuiApi
' by following the steps specified above, the following
' statment should be suficient for either development or run mode
sConnectionString = Command
If sConnectionString = "" Then
sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"
End If
' connect to a running SBO Application
SboGuiApi.Connect sConnectionString
' get an initialized application object
Set Application = SboGuiApi.GetApplication()
End If
' Initialize the Company Object.
' Create a new company object
Set Company = New SAPbobsCOM.Company
'// Acquire the connection context cookie from the DI API:
Cookie = Company.GetContextCookie
'// Retrieve the connection context string from the UI API using the
'// acquired cookie:
ConnectionContext = Application.Company.GetConnectionContext(Cookie)
'// Set the connection context information to the DI API:
If Company.SetSboLoginContext(ConnectionContext) = 0 Then
Counter = 0
Do While Company.Connected = False
' connect to company
If Company.Connect <> 0 Then
'
' Allow 10 connection failures before giving up
'
If Counter = 10 Then
Call Company.GetLastError(ErrorCode, ErrorMessage)
Call Application.MessageBox("Error Connecting to company database. Code is '" & ErrorCode & "' and error message is '" & ErrorMessage & "'")
ReturnValue = False
Exit Do
End If
'
' Wait longer each iteration
'
Call Sleep(Counter * 500)
Else
'
' set success condition
'
ReturnValue = True
End If
Counter = Counter + 1
Loop
End If
ErrorTrap:
If Err Then
'
' display message
'
Call MsgBox(Err.Description, vbOKOnly + vbCritical)
ReturnValue = False
End If
SetupApplication = ReturnValue
End Function
User | Count |
---|---|
102 | |
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.