cancel
Showing results for 
Search instead for 
Did you mean: 

Mac/Linux trigger Java GUI Scripting from command line

0 Kudos

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?

View Entire Topic
robert_straub
Advisor
Advisor
0 Kudos

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

0 Kudos

Sweet, thanks for sharing!

Do you have any link / PDF on the flags for SAPGUI?

0 Kudos

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