SAP provides the SAP Java Connector (SAP JCo) to enable communication in the SAP Web Application Server between the ABAP and Java stacks. SAP JCo can be used for the internal communication of the SAP Web Application Server, where the ABAP personality and the J2EE servers interact using SAP JCo.
You set up the JCo by registering the J2EE server as an RFC server to a SAP Gateway. This method, which is based on Remote Function Call (RFC) works in both directions:
Java calls BAPIs and RFC-enabled Function Modules (RFM) on the ABAP side and acts as a client.
ABAP calls functions on the Java side that acts as a server.
Calls from the SAP system are processed by the RFC Engine service of the J2EE Engine. It dispatches the call to a stateless session bean, which is registered in the Java Naming and Directory Interfaces (JNDI). Following the naming convention, the JNDI name used is identical to the name of the SAP function module. To parse the function calls from the SAP system correctly, the JCo needs access to a SAP system repository.
The following graphic shows how you can configure the JCo for high availability.
1. On startup of the RFC Engine service (that is normally the startup of the J2EE server), the service:
a. Connects to the SAP system repository
b. Registers itself at the gateway with a defined name.
It is possible to register under different names and at different gateways. But note that there is only a 1:1 relation between a name and a particular gateway. This has implications for high availability that are discussed below.
2. An SAP system calls a function for the registered RFC destination. The function has to be defined in the repository.
3. The gateway forwards the call to the RFC Engine.
4. The RFC Engine looks in the JNDI for the Enterprise JavaBeans (EJB), which is registered under the same name as the function module in the SAP system.
5. The RFC Engine calls the method processFunction(JCO.Function) of the EJB.
6. The results of the call are passed to the gateway.
7. The gateway passes the results back to the SAP system.
The RFC Engine service can register under one name to one particular gateway. To register to another gateway, another name has to be used.
In the SAP system, you can configure an RFC connection under one name for one particular external program that has to be registered at the gateway. Optionally you can specify a particular gateway for the connection.
Within a J2EE cluster, all J2EE servers configure the RFC Service identically. This means that a particular program registration is valid on all servers and points to the same gateway, as shown in the graphic below. The gateway balances requests between different servers that are registered under the same program name.
J2EE Servers in a Cluster
If one J2EE server fails, the RFC connection still works with the other server in the cluster. However, if the gateway fails, the RFC connection no longer works, because a particular program name can only be registered at one particular gateway.
You can set up the gateway in one of the following ways:
· Each SAP instance has its own gateway service (sapgw<systemnumber>) where external programs can be registered.
· With the standalone SAP Gateway, you can install the gateway service separately from the SAP system, for example, on the same host as the J2EE server(s). In this case, the SAP system can access each external gateway under a different RFC connection.
Choose the gateway setup that best fits your application scenario. When you use an option with different RFC connections, the ABAP application has to be aware of this.