on 05-16-2011 12:44 PM
Hello,
this is the first time i try to handle some actions from MS Access to SAP.
I have tried to record a script with the SAPGUI Script recorder. The Script works fine. I start it with the playback funktion (ALT + 12 -> record and playback) of SAP.
So the idea is now to start that vb script from my MS Access form by clicking a single button. Because starting the script by pressing ALT + F12 -> record and playback function -> searching the right vb file -> and pressing the green play Button take to much time in my opinion.
Would that be possible?
I have no idea how i could handle this?
Thanks for help!
I did it!
The problem was the Session attribut.
This Code works:
Private Sub Test_Click()
If Not IsObject(SAPGuiApp) Then
Set SAPGuiAuto = GetObject("SAPGUI")
Set SAPGuiApp = SAPGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = SAPGuiApp.Children(0)
End If
If Not IsObject(SAP_Session) Then
Set SAP_Session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject SAP_Session, "on"
WScript.ConnectObject SAPGuiApp, "on"
End If
SAP_Session.findById("wnd[0]").Maximize
SAP_Session.findById("wnd[0]/tbar[0]/btn[3]").press
...
End Sub
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.
Okay thanks, that works, but the script then stops at
Session.findById("wnd[0]").Maximize
with Error 438 "Object Doesn't Support This Property or Method"
May you help me again?
Thanks a lot
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bye the way...
Thank you for the trick with drag & drop the file to SAP
Is it possible to Link that vb File to my favorites in SAP, so i can only klick on the Favorite and the Makro starts? I´ve tried to do that, but the only thing i get is, that SAP opens Notepad and i see my Makro Code, but not a running makro.
Quick and dirty solution But i also want to get my solution with Access, but i can´t, don´t understand the way of connection SAP and Access...
Any help...?
thanks!
Edited by: Master-Rudi on May 16, 2011 4:47 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Master-Rudi,
I suspect that Access does not understand the reserved word "application". Within Access or Excel, you should use another term for "application". For example, as follows:
Private Sub Test_Click()
If Not IsObject(SAPGuiApp) Then
Set SAPGuiAuto = GetObject("SAPGUI")
Set SAPGuiApp = SAPGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = SAPGuiApp.Children(0)
End If
If Not IsObject(Session) Then
Set Session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject Session, "on"
WScript.ConnectObject SAPGuiApp, "on"
End If
Session.findById("wnd[0]").Maximize
....
End Sub
Regards,
ScriptMan
Hi Scirpter Man,
I am writting a Script and stuck in one area.I am not strong in VB.
Here is what My requirement.
When I am running the script there are lot of error records. But Every time My script is failing due to CIF or POP Error. I want to get rid of this error and the second one is I Want to log all the error records in one field so that I can track them seperatly.
This is very critical for my project Can you please help.
Thanks in Advance,
Regards,
Vamsi.P
Hi Rudi,
yeah that's possible..-
Place a Button on a Form and Put the Script you've recorded into the "CLick" Event of this Button.
That Should do the Trick
Greetings
Thomas B
PS
in Case you didnt know...
You can Drag n Drop the *.vbs File to your SAP-Window ...
If you need to know more about VBA / SAP Scripting just look at the following threads (dont worry becaus Excel is written-
it's the same stuff in Access
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the quick answer. But i have already tried that, but it doesn´t work.
That my Code:
Private Sub Test_Click()
If Not IsObject(Application) Then
Set SAPGuiAuto = GetObject("SAPGUI")
Set Application = SAPGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = Application.Children(0)
End If
If Not IsObject(Session) Then
Set Session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject Session, "on"
WScript.ConnectObject Application, "on"
End If
Session.findById("wnd[0]").Maximize
....
End Sub
The first problem doing this like you have posted is that, Access has a problem with .Children(0). If i delete the following part
If Not IsObject(Connection) Then
Set Connection = Application.Children(0)
End If
If Not IsObject(Session) Then
Set Session = Connection.Children(0)
End If
Access is marking the line
Session.findById("wnd[0]").Maximize
and say that Error 438
an a problem with the object which is not supporting that method or property
(sorry i don´t have the original English Error message, only in German)
Can you help me again?
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.