on 05-22-2013 8:54 PM
For some Circumstances I have to switch from VBA / VB6 to VB.NET-
So since 2 Days I am Trying to Convert my Codings.
Only thing thats left is the Connection to SAP
So far i have done it
Currently looks like this:
Module:
Public SapApplication as Object
Public SapGuiAuto as Object
Public SApSession as Object
Public SApConnection as Object
Now i want to Create a "global" connection - so far its working-
If Not isReference(SapApplication) Then
SapGuiAuto = GetObject("SAPGUI")
SapApplication = SapGuiAuto.GetScriptingEngine
End if
Thats simply enough for Writing and Reading Values from SAP
but Somtimes i need the session - for Information about Program and Transaction-
So i create the Session in a single Sub - proof the values and close the Session -
but the "barberpole" in the right corner won't stop spinning ? (like it used to do in VB 6 / VBA)
For certain Reasons i cant use the Connector mentioned in other threads 😞
So - what is the "right" way to Connect for the Session ?!
cheers
Thomas
Hi Thomas.
You need to clear the variable.
Set Session = Nothing
Then your session is released. This happen when you use gloal variables. Local variables (in a procedure) will release automatically when 'End Sub' is reached.
Br, Holger
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Holger, and all others ...
this is getting me freaking out...
there is seamly no way to get this thing to work correct...
If i put the session in a Private Variable and an Extern Function (like this)
Public Function GetTransaction_Programm () as String
Dim SapSession as Object
SapSession = SapConnection.Children(0)
With sapSession
t1 = .Info.Transaction
t2 = .Info.Program
end with
Dim Sapsession = Nothing 'doesnt matter,....
GetTransaction_Program = t1& "|" & t2
End Function
it should work - at least in VBA and VB 6 it worked ...
not in VB.Net
It doesnt matter how its put - the session is always terminated (so i could find out ) - but the "Scripting-sign" is still alive ?!?!
It disappears only if The Exe is Terminated ... ?
Br
Thomas
Hello Thomas.
Have you set anywhere gc.collect() to free memory of this object after Sapsession = Nothing or dispose this object (class?)?
Sounds like your issue is caused by this object as it is still active from memory. When exe is killed memory is cleared as well.
Br, Holger
Message was edited by: Holger Köhn (grammar issue)
Holger Köhn wrote:
Interesting. Seems like I need to develop myself and walk into VB.NET jungle. That sounds like I will feel like home 🙂
Great to hear that you find the way. DOTNET sounds like a lot of fun. Br, Holger
You bet ...
Its nothing like before in VB(6) or vba ...
its a complete new Universe -
To me VB(6) was more comfortable as to make a little helper (some quick n dirty ....) was faster done as in .NET but it has some Things you didnt have in the old VB ...
If you want to try you can download the newest Express Versions (2012 - dont get shocked about the IDE ... (its already Windows8 Design....*yuck*))
br
Thomas
Finally I found a solution to the Problem-
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
This works like a Charm ....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I also have the same issue of barber pole running at the bottom on the SAP screen . Could you please give a hint of how to modify the settings of release in VB express 2013.
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.