cancel
Showing results for 
Search instead for 
Did you mean: 

How to execute SAPgui.exe from java code

Former Member
0 Kudos

Hi All,

Can any one provide me the exe file name of SAP GUI related.

I need to call the SAP GUI related exe file from java.

i tried with a small java prog which executes the exe files.

it works fine with notepad.exe,javac.exe . But i am unable to execute the SAPgui.exe.

This is my java code

-


try{

Runtime rt=Runtime.getRuntime();

//String str= "C:
WINNT
system32
notepad.exe";

//Process pp=rt.exec("C:
j2sdk1.4.2_08
bin
javac");

Process pp=rt.exec("C:
Program Files
SAP
FrontEnd
SAPgui
SAPgui.exe");

BufferedReader br=new BufferedReader(new InputStreamReader(pp.getErrorStream()));

String line;

while ((line = br.readLine()) != null) {

System.out.println(line);

}

}catch(Exception e){

System.out.println(e);

}

and may i pass any additional parameters inorder to invoke this exe.

Please share your ideas abt this problem.

Its Urgent PLZ

Adv Thanks

Regds

Phani.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi rajesh,

to laungh sapgui.exe end logon into a sap system you have to use this string:

String str= "C:\Programmi\SAP\FrontEnd\SAPgui\Sapgui.exe hostName systemNumber";

you can use also the complete connection string:

sapgui /H/<SAP router 1>[/S/<SAP router service 1>][...]/H/<host>/S/<service>

Or if you want only to launch saplogon.exe you can use

String str= "C:\Programmi\SAP\FrontEnd\SAPgui\saplogon.exe";

Hope this help

Francesco

Former Member
0 Kudos

Hi,

Thanks for your response.

I am getting one exception at the time of execution

-


java.io.IOException: CreateProcess: C:\Programmi\SAP\FrontEnd\SAPgui\Sapgui.exe 10.113.10.201 3200 error=3

-


Can you send me the full code how to resolve this problem.

ADV Thanks

Rajesh

Former Member
0 Kudos

hi Rajesh,

here my complete code:

		try{
			Runtime rt=Runtime.getRuntime();
//			String str= "C:\Programmi\SAP\FrontEnd\SAPgui\saplogon.exe";
			String str= "C:\Programmi\SAP\FrontEnd\SAPgui\Sapgui.exe 10.113.10.201 00";
			//			Process pp=rt.exec("C:\j2sdk1.4.2_08\bin\javac");
			Process pp=rt.exec(str);
			BufferedReader br=new BufferedReader(new InputStreamReader(pp.getErrorStream()));

			String line;

			while ((line = br.readLine()) != null) {

			System.out.println(line);

			}

			}catch(Exception e){
			System.out.println(e);
			}

	}

Please note that system number is only two digit and in your case is 00.

Another important think, i'm using the italian version of windows, so the program directory is c:\programmi, please change into c:\program files, or you can modify your code to be language indipendend using an system environment variable (if exist).

Hope this help

Francesco

Former Member
0 Kudos

Hi Bersani,

Thanks alot for your help.

I got the logon pad and sapgui also.

One bit more can i call one Transaction ME23 and pass the Purchase Order number as an input(4500006370) from the same program with client 800

If so plz provide me the corresponding code

Thanks & Regards

Rajesh

Former Member
0 Kudos

Hi Rajesh,

i'm not completely sure, but i don't think it's possible logon and call a transaction from command line.

In this thread there is a discussion on how to open the gui, logon and call a transaction from a web page...

Hope this help

Francesco

Happy new year!!!!!