Server Programming in JCo Part 3

This is a continuation of Server Programming in JCo Part 2. In this post, I will deal with receiving and parsing the actual call from SAP.

In the previous post, the setup of the JCO.Server class was explained. To actually do anything with this class, we have to override the handleRequest() method. This method gets called when ever the SAP system with the proper credentials contacts your server.

In the handleRequest() function, There are 2 important tasks that are almost always included:

  1. Get the parameters for input, output, and table structures using the JCO.Function class
  2. Checking the function name to make sure the right code is run

[Read more...]

Server Programming in JCo Part 2

This is a continuation of Server Programming in JCo Part 1. In this post, I will deal with the setting up the constructs of the java program acting as the server.

The key Java object in JCO server programing is the JCO.Server, which is easy to use, but very powerful. At a high level, only these three things are needed to setup the server class:

  1. extend the JCO.Server class
  2. in your constructor, call one of the JCO.Server constructors
  3. override the handleRequest(JCO.Function function) method

Below is an example of a basic server setup. When the Server is running, all requests coming from the configured SAP system, will be sent to the handleRequest() function

[Read more...]

Server Programming in JCo Part 1

the SAP Java Connector, or JCo library, is an SAP delivered tool for connecting programs written in Java to the R/3. Most articles deal with external applications connecting to SAP R/3, but JCo provides the capability for SAP to call your java application as well. In this blog post, we’ll cover how to correctly setup SAP to call your java application.

In this first installment, I will just cover basic architecture and connection needs.
To create and run a java server successfully, we need the following two things:

  • Proper connection Parameters
  • A function template of your function in R/3

Proper Connection Parameters

In order to connect and use the JCo Server with R/3, the following items must be known:

  • Gateway host – The SAP gateway server name or IP address
  • Gateway Service Number – The service number is related to the SAP system number and starts at sapgw00
  • Program ID – The Program ID must match the Program ID registered in SM59

This information is available most likely from a Basis administer. The RFC registration matching is a common problem. The a sample Program ID is shown below. This HAS to match the program ID you start your JCO.Server object with.

SM59 Registration Configuration

SM59 Registration Configuration

Functional Template

A JCo server needs to have the skeleton of the program in R/3. SAP cannot just call your external java program without the import, export, and table parameters defined within the system. Instead of creating a custom RFC for this example, I’ll use a pre-existing one. remember, we are only using the import, export, and table parameters, the code is running on our java server. The BAPI we are going to use is BAPI_CUSTOMER_GETDETAIL.

After these two things are in place, we are ready to start coding.

The next post will cover:

  • JCO.Server Object
  • JCO.Repository Object
  • JCO.Client Object

The next posting is Server Programming in JCo Part 2