4

We are trying to communicate with SAP R/3 from a standalone java application We will use the JCo 3.0 libraries for this.

From the documentation I understood that there are 2 ways to connect with SAP.

  1. as a JCo Client
  2. as a JCo Server

At first I was convinced that our application would need to connect as a JCo client. But I am starting to doubt.

Our application sends data. (e.g. update of order status) But our application also receives data (e.g. SAP pushes changes to the master data - MATMAS).

So, does it need to be a client or a server ?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
bvdb
  • 22,839
  • 10
  • 110
  • 123

2 Answers2

5

There is no JCo Client in the JCo 3.0 API model but only JCoDestinations instead which replaced the old JCO.Client from the 2.1 API model.

And the 2 ways to connect to SAP via the RFC protocol are:

  1. Inbound RFC communication (as an RFC client / Java calls ABAP)
  2. Outbound RFC communication (as an RFC server / ABAP calls Java)

For inbound RFCs you need to use a JCoDestination for executing a remote function module at ABAP side. For outbound RFCs you need to register a JCoServer at the SAP gateway which will then receive incoming requests from ABAP side in order to process a remote function module at Java side. In both communication directions there is a request and potentially also a response to this request, so the data flow is in both directions for inbound and outbound RFC communication. Inbound and outbound just distinguishes who initiates the RFC call.

And regarding the JCoServer, you usually also need to define some JCoDestination as well for a repository, because this is needed by a default JCoServer for querying required RFC metadata from an ABAP back-end. Without such a JCoRepository, a JCoServer would not be able to interpret the incoming RFC request data. So in a typical JCo server scenario you need both: a JCoServer and a JCoDestination (for the server's JCoRepository).

You can use the same configuration for the JCoDestination for both use cases (client calls and repository queries), but SAP recommends to define separate configurations which is more flexible regarding the definition of connection pool sizes and allows separate RFC authorizations for both use cases.

Trixx
  • 1,796
  • 1
  • 15
  • 18
  • Even if the class is not called a client any longer, its function is still to act as a client. – vwegert Feb 27 '17 at 21:47
  • @vwegert: There's semantically a difference between a client and a destination. The old `JCO.Client`represented a concrete RFC connection, whereas the new `JCoDestination` represents an abstract target system, just like a destination that is defined in transaction SM59 at ABAP side. – Trixx Feb 28 '17 at 07:36
  • I partially agree with @vwegert; in my opinion the `JCODestination` is still a client. SAP delivers example java files to illustrate the use of the `JCODestination`, and even they call this example "Step by step client". - On the other hand I like the way you formulated it in your answer. You clearly explain that using the word "client" can be confusing as it also could refer to a legacy class. - From now on I'll use the words "inbound" and "outbound". – bvdb Feb 28 '17 at 08:42
  • @bvdb: The "Step by step client" example shall illustrate how to act as an RFC client. And yes, it can be confusing because most people have the old `JCO.Client` class in mind when speaking of a "JCo client". If one could say so, a `JCoDestination` creates, manages and uses `JCoClient` connection objects internally which are not handed out anymore in the new JCo 3.0 API model. – Trixx Feb 28 '17 at 10:34
0

Both. Actually, you need a client connection to initiate a server connection, so when you setup the server connect, you'll automatically get the client connection as well.

vwegert
  • 18,371
  • 3
  • 37
  • 55
  • Are you refering to both ends of the communication, i.e. that a client Jco connects to a server Jco ? or do you mean that 1 single instance needs to be both a client and server at the same time ? Because I can perfectly create a server without creating a client first: `JcoServer server = JCoServerFactory.getServer(SERVER_NAME);` – bvdb Feb 27 '17 at 16:01
  • You can do that because you have specified a client connection that tells the JCo how to reach that server somewhere else. – vwegert Feb 27 '17 at 21:48