Registering a Server Application at the SAP Gateway
To receive RFC calls from an R/3 client, a server application program running on an external computer must be registered in an RFC destination at an SAP Gateway. This means that you must first define an RFC destination suitable for your needs.
Defining an RFC Destination in the Calling R/3 System
To define an RFC destination on the R/3 system that will be making client RFC calls to your server application program, use Transaction SM59. In this transaction, enter an RFC destination name; for example,
MYDEST . You must select T for the Connection Type and REGISTRATION for the Activation Type. Then, enter MYDEST as the program ID. After you enter this information, you are ready to save this RFC destination definition.Defining an RFC Destination on the Application's Computer
Destination Entry in the saprfc.ini File
The RFC destination that you defined above must be reflected in the saprfc.ini file where your server application resides.
Note that in the following example saprfc.ini file,
nnn.nnn.nnn.nnn is the IP address of the computer hosting the SAP Gateway (which usually resides on the same server as the R/3 system). If you wish, you do not have to use the IP address to specify the host. You can also enter the host name of the host. Also in the example below, the entry GWSERV is set to sapgw?? , where ?? is the system number of the R/3 application server.DEST=MYDEST
TYPE=R
PROGID=mydest
GWHOST=nnn.nnn.nnn.nnn
GWSERV=sapgw??
RFC_TRACE=1
Location of the SAPRFC.INI Files
You must place a copy of the saprfc.ini file in one of two places:
Example:
RFC_INI=C:\myprojects\rfc\java\saprfc.ini
Referring to the Destination in Your Server Application
You specify the destination to use in your server application by using the setAcceptArgs(String[]) method of the ServerApp object.
You specify the destination as a string containing the destination name prefixed with "-D" (note that it must be the uppercase letter D). The destination name is the same as you defined in your saprfc.ini file and on the R/3 system. You assign this string to the first element of the argument to setAcceptArgs.
Example
The following example sets the RFC destination for the server application. It assumes that all the necessary objects and variable have been defined earlier.
// _serverApp is a reference to the single instance
// of com.sap.rfc.ServerApp class
String[] acceptArgs = new String[1];
acceptArgs[0] = new String();
acceptArgs[0] = "-DMYDEST";
_serverApp.setAcceptArgs(acceptArgs);
// Use uppercase D ("-D")
// in the string in acceptArgs[0] = "-DMYDEST";