cancel
Showing results for 
Search instead for 
Did you mean: 

GUIxT and SAP GUI Script

Former Member
0 Kudos

I am running GUI client 710 and the related GUIxt.

1) I need a button (GuiXt on a particular set of TCODE FB03, ...) - Done.

2) I need VBS script that will launch Image Now with the current windows user - Done

3) I need to link the button press trigger the execution of the script.

Some success. I have a script that I attach manually to SAP Login, and it runs in the background the waiting. It launches Image Now when a new session is created.


Dim objSapGui
Set objSapGui = GetObject("SAPGUI") 

Dim objScriptingEngine
Set objScriptingEngine = objSapGui.GetScriptingEngine
WScript.ConnectObject objScriptingEngine, "Engine_"

Dim Waiting
Waiting = 1

Do While (Waiting = 1)
 WScript.Sleep(100)
Loop  
 
Set objScriptingEngine = Nothing
Set objSapGui = Nothing
 
Sub Engine_CreateSession(ByVal Session)
  Set WshNetwork = WScript.CreateObject("WScript.Network")
  Set WshShell = WScript.CreateObject("Wscript.Shell")
  Command = """C:\Program Files\ImageNow6\bin\sap_view.vbs """ &  WshNetwork.UserName & " PASSWORD ,0"
  WshShell.Run Command
End Sub

How do execute a similar sub when /app/con[0]/ses[0]/wnd[0]/tbar[1]/btn[6] is pressed (This is value from the Hit test )?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thank you for your help. You are correct and I was able to remove the Object Required: WCRIPT error using the CreateObject Command. This has definitely been a learning experience. I wrote a JSCRIPT and a VBSCRIPT version.

VBSCRIPT



Dim answer
answer=MsgBox("Would you like to launch ImageNow",65)

if answer = 1 then
Dim objSapGui
Set objSapGui = GetObject("SAPGUI") 

Dim objScriptingEngine
Set objScriptingEngine = objSapGui.GetScriptingEngine
Set wshshell = CreateObject("WScript.Shell")
Set WshNetwork = CreateObject("WScript.Network")
Command = """C:\Program Files\ImageNow6\bin\sap_view.vbs """ &  WshNetwork.UserName & " PASSWORD ,0"
WshShell.Run Command

end if

Both scripts work with SAPGUI 710. I am still waiting on SYNACTIVE to provide me with the InputAssistant demo key in order to attach my code to a new button, but in the meantime I am using GUIxt and the keyword applyguiscript to execute my VBSCRIPT version each time FB03 is displayed. The script has a MSGBOX that allows them to open IMAGENOW if they require it.

Again Thank you for your suggestions

Former Member
0 Kudos

Thank you for taking the time to review my question.

I have tried to execute a similar script by dragging it onto the SAP GUI, as well as using GUIXT to //applyscript automatically when the screen is launched, but I get a message stating " OBJECT required: WSCRIPT".

I have requested a demo key from Synactive for input assistant in order to try the process="script.txt" functionality but have not received it yet.

Some related questions and again, I thank you for your effort.

1) Is it possible to provide the GUI with some way to use WSCRIPT allowing me to use my current VBSCRIPT

2) I have written an alternative using JSCRIPT that works when "dropped" on to the SAPGUI, but GUIXT will only use VBSCRIPT. Can I call a JSCRIPT from within a VBSCRIPT without needed WSCRIPT?

Thank you

script_man
Active Contributor
0 Kudos

Hi Felix,

You can also call a VBScript from another VBscript like this:

set Wshell = CreateObject("WScript.Shell")

wshell.run "wscript.exe ""c:\tmp\test.vbs"

or

set Wshell = CreateObject("WScript.Shell")

wshell.run "wscript.exe ""c:\tmp\test.vbs"" /Parameter"

or

set Wshell = CreateObject("WScript.Shell")

wshell.run "wscript.exe ""c:\tmp\test.vbs"" /Parameter", 1 , true

etc.

The error (" OBJECT required: WSCRIPT") should then not happen again.

I have not worked with JScript. But I suspect that it would to go like this.

Regards,

ScriptMan

script_man
Active Contributor
0 Kudos

Hi Felix,

I have no solution but only a few suggestions.

For example:

On "/6" Fcode="/6" Process="test.txt"

test.txt:

Screen *

ApplyGuiScript "test.vbs"

Enter

Regards,

ScriptMan