tags:

views:

176

answers:

2

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?

+1  A: 

Hello,
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

PATRY
A: 

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.

Chris Carruthers