SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Error while running a VBS script

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Error while running a VBS script
Author Message
Patricia



Joined: 09 Apr 2013
Posts: 1
Country: Netherlands

Post Error while running a VBS script Reply with quote
I would like to run a vbs script in SAP, but I get the error below.



the test script:
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
session.findById("wnd[0]/tbar[0]/okcd").text = "mm03"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").text = "tax reference"
session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").caretPosition = 13
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/usr/tblSAPLMGMMTC_VIEW").getAbsoluteRow(0).selected = true
session.findById("wnd[1]").sendVKey 0
Tue Apr 09, 2013 8:48 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 6501

Post Reply with quote
The error you get is likely because you didn't set the job script type correctly. It is likely current set to JavaScript, not VBScript.

In addition that script will not work as is. First of all there is no WScript object in VBScript for applications, secondary, it won't work in non-graphical and in unattended mode especially when the scheduler is running is service. Only in full graphical mode you can use "SendKeys" to simulate keyboard events. And even that is highly unreliable. Imagine that while you are running that king this script some window popup will get in the way and grab system focus, or some other application popup. What could happen after that is anyone's guess.

PS. My two cents opinion... Chaining function calls like "session.findById("wnd[0]").sendVKey" doesn't help at all. It is just as bad as 3 separate function calls, it doesn't cause windows and other applications to stop working while the code is being executed. My suggestion, anything that requires sending keystrokes and mouse events is a non starter for a robust automation solution. Please look for an internal API or some other programmatic method to automate the same.
Tue Apr 09, 2013 9:35 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.