Skip to Content
0
Jan 22, 2020 at 10:49 PM

Mac/Linux trigger Java GUI Scripting from command line

399 Views Last edit Jan 23, 2020 at 09:11 AM 2 rev

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?