on 09-19-2014 1:37 PM
Hello everyone,
I have been trying to start a new SAP session from scratch by calling its API from the Excel VBA. Thanks to this forums I've managed to start a new SAP window, enter my credentials and successfully log in to the system. However, I can only think it is successful because when the credentials are correct, the window disappears and nothing happens after that. If I enter the incorrect credentials, it won't let me through which I understand as a sign that the session is properly connected to the database.
Is there any way to force the SAP GUI keep open after I log in? Is it normal that it disappears?
The code I use to prompt the logon window:
If SapGuiApp Is Nothing Then
Set SapGuiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If Conn Is Nothing Then
Set Conn = SapGuiApp.OpenConnectionByConnectionString("mycompanyserver.com", True, False)
End If
If SAPSesi Is Nothing Then
Set SAPSesi = Conn.Children(0)
End If
After that I want to be able to run the macro the following way:
With SAPSesi
.findById("wnd[0]/tbar[0]/btn[12]").press
.findById("wnd[0]/tbar[0]/okcd").Text = "TRANSACTION"
.findById("wnd[0]/tbar[0]/btn[0]").press
etc.
Thank you!
Krzysiek
Hello Krystof. Once the procedure (macro) is done all objects got cleared. Fillin a messagebox before your code end:
msgbox "Wait to check session Frame..."
Best regards,
Holger
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Holger,
Thank you for such a quick response.
I added the msgbox but it didn't help. I have never actually run the macro all the way down at once, I was always going line by line. The logon window appears on this line:
Set Conn = SapGuiApp.OpenConnectionByConnectionString("mycompanyserver.com", True, False)
then I run the procedure down to Set SAPSesi = Conn.Children(0), enter my credentials and press Enter. The SAP window disappears, but procedure is "running", being stopped at the last line of it.
I know the objects are not cleared because 'If SapGuiApp Is Nothing Then' tests for false.
The screenshot was taken right before I press Enter, after that the SAP closes and macro stays at MsgBox line.
Can this be because I use the old SAP interface?
Regards,
Krzysiek
Still no luck. I get the following error for using SendCommand or any other piece of code that tries to connect with SAP GUI:
I have a feeling that there is no connection with SAP GUI at all or there is one up until I log in.
Two more things that may be important:
1) SAP is on Citrix environment
2) I use the address from "Message Server" column in SAP Logon Pad as the server address in OpenConnectionByConnectionString method, not sure if that's the correct one
Thank you for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.