on 2020 Jan 22 10:49 PM
Scenario
I am able to trigger a javascript file from command line like this:
test1.js
application.openConnectionByConnectionString("conn=/H/10.10.10.100/S/3200&expert=true");
application.findById("/app/con[0]/ses[0]/wnd[0]/usr/txtRSYST-MANDT").text = "220";
application.findById("/app/con[0]/ses[0]/wnd[0]/usr/txtRSYST-MANDT").setFocus();
application.findById("/app/con[0]/ses[0]/wnd[0]/usr/txtRSYST-MANDT").caretPosition = 3;
application.findById("/app/con[0]/ses[0]/wnd[0]/usr/txtRSYST-BNAME").text = "username";
// The text of a password field is not recorded. Either enter a valid password or delete the following line
application.findById("/app/con[0]/ses[0]/wnd[0]/usr/pwdRSYST-BCODE").text = "secret";
application.findById("/app/con[0]/ses[0]/wnd[0]").resizeWorkingPane(181,35,false);
application.findById("/app/con[0]/ses[0]/wnd[0]").sendVKey(0);
application.findById("/app/con[0]/ses[0]/wnd[0]/tbar[0]/okcd").text = "/nex";
application.findById("/app/con[0]/ses[0]/wnd[0]").sendVKey(0);
#!/bin/bash
export SAPGUIDIR="/Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources"
export WORKDIR=`pwd` # this is where the script file is located
cd "${SAPGUIDIR}"
echo "[DEBUG] starting..."
java \
-cp Java/GuiStartS.jar com.sap.platin.Gui \
-n \
-b \
-f ${WORKDIR}/test1.js
echo "[DEBUG] done!"
Problem
JavaGUI does not quit. There is a popup that says "The script has successfully completed its execution".
If I run the command again, I get another copy of JavaGUI running ...
How can I get JavaGUI to quit completely?
Please could anyone share a link to the full JavaScript API?
Request clarification before answering.
On macOS just add parameters "-t NOPHANTOM" in the script, then the JavaGUI will exit when the connection is closed.
And instead of calling "java ... -jar GuiStartS.jar..." you can call
"/Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/MacOS/SAPGUI -n -b ...."
This will start the JavaGUI with the appropriate java version.
Regards
Robert
SAP GUI for Java
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great - the GUI does not remain active after the script.
"${SAPGUIDIR}/MacOS/SAPGUI" \
-n \
-b \
-t NOPHANTOM \
-f ${WORKDIR}/test1.js
But it's messy... note this line in the output : TRC and AUTDMP were not requested?
31.01. 17:01:49.270 TRC: Active trace keys: NOPHANTOM:TRC:AUTDMP
2020-01-31 17:01:48.845 SAPGUI[78711:3683840] Task succeeded.
31.01. 17:01:49.269 TRC: -----------------------------------------------------------
31.01. 17:01:49.269 TRC: Date: 31.01. 17:01:49.257
31.01. 17:01:49.269 TRC: -----------------------------------------------------------
31.01. 17:01:49.269 TRC: System Details
31.01. 17:01:49.269 TRC: -----------------------------------------------------------
31.01. 17:01:49.269 TRC: Java VM: Oracle Corporation Version 10.0.2+13
31.01. 17:01:49.269 TRC: Bit Mode: 64
31.01. 17:01:49.269 TRC: OS: Mac OS X(x86_64) Version 10.15.3
31.01. 17:01:49.269 TRC: Java Directory: /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home
31.01. 17:01:49.269 TRC: Home Directory: /Users/derek
31.01. 17:01:49.269 TRC: Current Directory: /Applications/SAP Clients/SAPGUI 7.50rev5
31.01. 17:01:49.269 TRC: Locale: English (United Kingdom)
31.01. 17:01:49.269 TRC: Default Character Encoding: UTF8
31.01. 17:01:49.269 TRC: -----------------------------------------------------------
31.01. 17:01:49.269 TRC: Product Details
31.01. 17:01:49.269 TRC: -----------------------------------------------------------
31.01. 17:01:49.269 TRC: SAP GUI for Java 7.50 rev 5
31.01. 17:01:49.269 TRC: 2018-12-05 06:30:12 +0100
31.01. 17:01:49.269 TRC: mo-f75228bd7, 750_REL, 1889363
31.01. 17:01:49.269 TRC: (Version ID A075000040500)
31.01. 17:01:49.270 TRC: Active trace keys: NOPHANTOM:TRC:AUTDMP <<====================== WHY???
31.01. 17:01:50.572 TRC: Installation Details
31.01. 17:01:50.572 TRC: -----------------------------------------------------------
31.01. 17:01:50.572 TRC: Private Glob File: /Users/derek/Library/Preferences/SAP/globs
31.01. 17:01:50.572 TRC: Desktop integration: Mac OS X integration (library: /Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources/bin/libMacOSXConnect64.dylib exists: true)
31.01. 17:01:50.572 TRC: -----------------------------------------------------------
31.01. 17:01:50.572 TRC: Path Information:
31.01. 17:01:50.572 TRC: -----------------------------------------------------------
31.01. 17:01:50.572 TRC: SAP GUI traces : </Users/derek/Library/Preferences/SAP/traces>
31.01. 17:01:50.572 TRC: SAP GUI user prefs : </Users/derek/Library/Preferences/SAP>
31.01. 17:01:50.572 TRC: SAP GUI system prefs : </Library/Preferences/SAP>
31.01. 17:01:50.572 TRC:
31.01. 17:01:50.572 TRC: Installation Dir : </Applications/SAP Clients>
31.01. 17:01:50.572 TRC: Product Dir : </Applications/SAP Clients/SAPGUI 7.50rev5>
31.01. 17:01:50.572 TRC: Application Dir : </Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app>
31.01. 17:01:50.572 TRC: Resource Dir : </Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources>
31.01. 17:01:50.572 TRC:
31.01. 17:01:50.572 TRC: Binary Dir : </Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources/bin>
31.01. 17:01:50.572 TRC: GMUX Dir : </Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources/bin/gmux>
31.01. 17:01:50.572 TRC: Jar Dir : </Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources/Java>
31.01. 17:01:50.572 TRC: Install Script Dir : </Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources/inst>
31.01. 17:01:50.572 TRC: Security Dir : </Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources/security>
31.01. 17:01:50.572 TRC: Documentation Dir : </Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources/doc>
31.01. 17:01:50.572 TRC:
31.01. 17:01:50.572 TRC: Default Installation Dir: </Users/derek/Applications/SAP Clients>
31.01. 17:01:50.572 TRC: System Installation Dir : </Applications/SAP Clients>
31.01. 17:01:50.572 TRC: User Installation Dir : </Users/derek/Applications/SAP Clients>
31.01. 17:01:50.572 TRC:
31.01. 17:01:50.572 TRC: Files:
31.01. 17:01:50.572 TRC: Installation Script : </Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources/inst/install>
31.01. 17:01:50.572 TRC: Deinstaller : <null>
31.01. 17:01:50.572 TRC: guilogon : </Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources/bin/guilogon>
31.01. 17:01:50.572 TRC: guistart : </Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources/bin/guistart>
31.01. 17:01:50.572 TRC: Installation LOCK : </Applications/SAP Clients/SAPGUI 7.50rev5/platin.lock>
31.01. 17:01:50.572 TRC: Installation Log : </Users/derek/Library/Logs/sapgui.log>
31.01. 17:01:50.572 TRC: Permissions : </Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/Resources/permissions>
31.01. 17:01:50.572 TRC: -----------------------------------------------------------
31.01. 17:01:50.572 TRC: List of active code sources
31.01. 17:01:50.572 TRC: -----------------------------------------------------------
31.01. 17:01:50.572 TRC: Classloader:com.sap.platin.micro.MicroURLClassLoader@1b2abca6
.... big snip ....
31.01. 17:01:50.572 TRC: -----------------------------------------------------------
31.01. 17:01:50.572 TRC: The jar folder contains the following jar files:
31.01. 17:01:50.572 TRC: -----------------------------------------------------------
31.01. 17:01:50.572 TRC: sapTextEditS.jar
31.01. 17:01:50.572 TRC: sapInputFieldS.jar
31.01. 17:01:50.572 TRC: sapJnetS.jar
31.01. 17:01:50.572 TRC: sapContextMenuS.jar
31.01. 17:01:50.572 TRC: JNetBeanS.jar
31.01. 17:01:50.572 TRC: plafbaseS.jar
31.01. 17:01:50.572 TRC: iCubeS.jar
31.01. 17:01:50.572 TRC: platincore9S.jar
31.01. 17:01:50.572 TRC: sapImageS.jar
31.01. 17:01:50.572 TRC: pdfViewerS.jar
31.01. 17:01:50.572 TRC: sapToolBarS.jar
31.01. 17:01:50.572 TRC: sapCalendarS.jar
31.01. 17:01:50.572 TRC: sapComboBoxS.jar
31.01. 17:01:50.572 TRC: sapPdfViewerS.jar
31.01. 17:01:50.572 TRC: platinsecS.jar
31.01. 17:01:50.572 TRC: sapHtmlCoreS.jar
31.01. 17:01:50.572 TRC: sapTreeS.jar
31.01. 17:01:50.572 TRC: sapChartS.jar
31.01. 17:01:50.572 TRC: sapHtmlS.jar
31.01. 17:01:50.572 TRC: GuiStartS.jar
31.01. 17:01:50.572 TRC: platinlangS.jar
31.01. 17:01:50.572 TRC: platinr3S.jar
31.01. 17:01:50.572 TRC: platinwdpS.jar
31.01. 17:01:50.572 TRC: platinMacOSXS.jar
31.01. 17:01:50.572 TRC: sapGridS.jar
31.01. 17:01:50.572 TRC: platincoreS.jar
In case someone comes across this thread and that they're having issues with SAPGUI for Java 7.80:
application.unwrap(application).mUnattended = true;
java.lang.System.exit(0);
java -Djava.security.policy=file://...
grant principal com.sap.platin.micro.GuiPrincipal "SAPGUI:UserScript" {
permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete,execute";
permission java.lang.RuntimePermission "getenv.*";
// Generic Permissions necessary for Scripting
permission javax.security.auth.AuthPermission "doAsPrivileged";
permission java.awt.AWTPermission "createRobot";
// Allow the script to exit
permission java.lang.RuntimePermission "exitVM";
};You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The public trace keys are listed in chapter "5.3.3 Trace Information" of the manual available via Help > SAP GUI Help. They usually are intended to switch on tracing in particular components for debugging purposes.
There are a few more to modify the behavior, but they are not published by intention.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using parameter -? will print the list of parameters.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
LOL, reverse-engineering the documentation...
...there is no mention of "NOPHANTOM" - not even the mighty Google has any record of this feature
"/Applications/SAP Clients/SAPGUI 7.50rev5/SAPGUI 7.50rev5.app/Contents/MacOS/SAPGUI" -h
2020-01-31 16:34:14.902 SAPGUI[77876:3663785] Task succeeded.
############################# ERROR #############################
31.01. 16:34:16.926 ERROR: Getopt.nextOption(): Unrecognized option: -h
############################# ERROR #############################
com.sap.platin.base.logon.GuiImpl: start program for PlatinGui
Usage: com.sap.platin.base.logon.GuiImpl [options]
Available options:
/Rfc=[0-9A-F][0-9A-F]* RFC id to send to backend during connect
-o <hostSpec>opens a connection to <hostSpec> (e.g. /H/binmain/S/3253)
-f <fileName>executes the script contained in the file <fileName>
-s <script>executes the script contained in string <script<
-w opens a script window for manual script input
-n doesn't show guilogon window
-t <traceKeys> activates all trace keys contained in string <traceKeys>
(delimited by commas, e.g. CON,SES,EVT,C_AGI)
-l <traceFile> writes trace information activated by trace keys with the option -t
into the log file <traceFile>
-p <libdir>path to the JPlatin library
-g <gmuxpath>path to Gmux
-b no progress bar
-? prints this help text
The options '-f' and '-s' may occur repeatedly and in any order (they are evaluated in the order
they appear).
For SAP GUI Scripting API please refer to
https://help.sap.com/viewer/b47d018c3b9b45e897faf66a6c0885a8/760.00/en-US
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.