English 中文(简体)
Open the SAP thick client screen from Java program
原标题:
  • 时间:2009-11-19 07:30:27
  •  标签:
  • java
  • sap

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 SettingsgpatrySapWorkDir  
[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.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签