开发者

Open the SAP thick client screen from Java program

开发者 https://www.devze.com 2022-12-12 11:46 出处:网络
Having any thick client like SAP Logon installed, users can connect to required SAP server and access data through transactions.

Having any thick client like SAP Logon installed, users can connect to required SAP server and access data through transactions.

What I am trying to do? - To invoke the SAP thick client installed in the users machine and redirect the user directly to required transaction from the service (in turn Java code)

What is posisble? - It is possible to do the same from SAP, based on generated ids. The following link will help -

http://wiki.sdn.sap.com/wiki/display/Snippets/Creating+a+SAP+shortcut+for+any+transaction+and+sending+it+by开发者_开发问答+mail

Is it possible to do the same through Java code?


You can create a .SAP file on the desktop with the following content:

example:

conn=/H/192.168.90.5/S/3210&clnt=300&lang=RO&tran=*ZME29N SO_EBELN-LOW=4500028729;
where 192.168.90.5 is the local sap server ip
3210 is the server port
300 is the client
RO - language
*ZME29N is the transaction followed by the select options.
  • (asterisk) means that the system will execute the transaction with the respective select options.


If you can connect your programme to SAP, you could always set the function from the wiki as RFC, and get the link from SAP. Otherwise, you can always test the function to check the return string.

this string can be used to create a SAP GUI Shortcut. those shortcups possess the .sap extension and contains the previous string. For exemple this is the content of a test SAP GUI shortcut :

[System]  
Name=IFR  
Description=IFR ECC 6.0  
Client=300  
[User]  
Name=gpatry  
Language=FR  
[Function]  
Title=Connexion SAP IFR  
Command=PA20  
[Configuration]  
WorkDir=D:\Documents and Settings\gpatry\SapWorkDir  
[Options]  
Reuse=0  

In in the example you gave, such string was use to create an attachement in the name of "DisplayAddress.SAP" . A click on the attachement launch the GUI.

If creating a shortcut is not suffisant, you may try to exec opening the shortcut file, in the same way that open a .doc launch word. I must admit my ignorance on this particuliar point.

hope this helps,
regards,
Guillaume


Guillaume (PATRY) is correct in the general approach to generating the .SAP shortcut content. An alternative approach if you are always launching a particular transaction is to use a hard-coded (or resource-retrieved) template.

You then need to save it as a file and launch the file. This can be done as follows:

// Generate your .SAP shortcut content by calling an RFC, or manually filling a template.
String shortcutContent = ...;

File file = new File(...some path, probably inside temp dir...);

OutputStream os = new FileOutputStream(file);
os.write(shortcutContent.getBytes());
os.close();

String url = "file://" + file.getAbsolutePath();

// Ask OS to launch the file
Runtime runtime = Runtime.getRuntime();
String cmd = "rundll32 url.dll,FileProtocolHandler " + url;
runtime.exec(cmd);

// Remove file
file.deleteOnExit();

You will of course need to add exception handling around this code appropriate to the surrounding architecture.

0

精彩评论

暂无评论...
验证码 换一张
取 消