on 06-08-2011 3:04 PM
I have been using Script Recording & Playback to output excel documents from CM01.
Everything works just fine and I have been very happy with the results.
Just the other day when I tried to play a script from the Script Recording & Playback interface..
Nothing happened.
I can still record new scripts with the interface, but when I click on the green arrow, select a file and click open, nothing happens.
(No errors and I am back to the original interface.)
If I have a SAP easy Access window open I can execute the .vbs file through Windows Explorer by double clicking on it.
Then everything works fine.
Does anyone have an idea on why this would be?
Thanks in advance.
Hi Sleepydog,
Unfortunately I have no explanation for the phenomenon. One thing is certain, however. By execute of the script from the Windows Explorer is always addressed the currently lowest SAP session. When you run the script from SAP is always addressed the straight current SAP session.
Example: Two SAP sessions are open. The following script provides two different results. The condition is that it starts from the highest SAP session.
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
msgbox session.info.sessionnumber
Regards,
ScriptMan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi SAPDyl,
You could use the following script:
If Not IsObject(SAPguiApp) Then
Set SAPguiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If Not IsObject(Connection) Then
Set Connection = SAPguiApp.OpenConnection("SYSTEM", True)
End If
If Not IsObject(Session) Then
Set Session = Connection.Children(0)
End If
Session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "400"
Session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "CASTLESD"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "PASSWORD1"
Session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"
Session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/okcd").text = "IW37"
session.findById("wnd[0]").sendVKey 0
'Here follows the recorded script without the first 14 rows.
As "SYSTEM" You have to use the name of your SAP - system. Please use the script recorder to record a script on ALT / F12.
Regards,
ScriptMan
Scriptman below is the code being run however error with logon, will open R/# but will not logon as user and password am i missing something? Seems to prompt for debug at session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "castlesd"
If Not IsObject(SAPguiApp) Then
Set SAPguiApp = CreateObject("Sapgui.ScriptingCtrl.1")
End If
If Not IsObject(Connection) Then
Set Connection = SAPguiApp.OpenConnection("1. SAP R/3 Production Environment", True)
End If
session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "castlesd"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "password1"
session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"
session.findById("wnd[0]/usr/txtRSYST-LANGU").SetFocus
session.findById("wnd[0]/usr/txtRSYST-LANGU").caretPosition = 2
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/okcd").Text = "/zqiw37_ser"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").maximize
MsgBox "If you click on the OK button, the SAP session is terminated."
End Sub
Hi Scriptman,
It has been a while, i am still having trouble with the below code to logon to R3, as far as i can get is to the logon, cursor flashing in the user name field. I have noticed the system and language fields are auto filled. If i remove Session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "400" still the same result in SAP and a error debug prompt at the line following the End If. Am i missing something again.
Thanks SAPDyl
If Not IsObject(SAPguiApp) Then
Set SAPguiApp = CreateObject("Sapgui.ScriptingCtrl.1";)
End If
If Not IsObject(Connection) Then
Set Connection = SAPguiApp.OpenConnection("1. SAP R/3 Production Environment", True)
End If
Session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "400"
Session.findById("wnd[0]/usr/txtRSYST-BNAME").Text = "castlesd"
Session.findById("wnd[0]/usr/pwdRSYST-BCODE").Text = "zxcvbnm"
Session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"
Session.findById("wnd[0]/usr/txtRSYST-LANGU").SetFocus
Session.findById("wnd[0]/usr/txtRSYST-LANGU").caretPosition = 2
Session.findById("wnd[0]").sendVKey 0
Session.findById("wnd[0]/tbar[0]/okcd").Text = "/zqiw37_ser"
Session.findById("wnd[0]").sendVKey 0
Session.findById("wnd[0]").maximize
MsgBox "If you click on the OK button, the SAP session is terminated."
End Sub
Hi SAPDyl,
I suspect that this time missing the following commands:
. . .
If Not IsObject(Connection) Then
Set Connection = SAPguiApp.OpenConnection("1. SAP R/3 Production Environment", True)
End If
'new commands
If Not IsObject(Session) Then
Set Session = Connection.Children(0)
End If
'new commands
Session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "400"
. . .
Regards,
ScriptMan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.