cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Script Record VB -> Start from MS Access

Former Member
0 Kudos

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!

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

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.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

script_man
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

script_man
Active Contributor
0 Kudos

Hi Vamsi,

welcome to the forum. I suggest you open a new thread. There you can display your code and report us the position, where the script runs on an error.

Regards,

ScriptMan

thomas_brutigam2
Active Participant
0 Kudos

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

Former Member
0 Kudos

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