Expand +



New Features in SAP Java Connector (JCo) 1.1

by Thomas G. Schuessler | SAPinsider

October 1, 2001

by Thomas G. Schuessler, ARAsoft SAPinsider - 2001 (Volume 2), October (Issue 4)

The SAP Java Connector (JCo) has quickly become very popular and deservedly so. Check out my article in the previous issue of this publication if you want a product overview. In the meantime, JCo 1.1 has been released (you can download it from In this article I would like to introduce you to the most important new features in version 1.1.


In JCo 1.0(, the two DLLs jRFC11.dll and jRFC12.dll needed to reside in the WINNT\SYSTEM32 directory. In JCo 1.1, those DLLs must be in the same directory as the jCO.jar file itself. This will allow you to have multiple versions of JCo installed on the same system in the future.

Multi-Platform Support

The first release of JCo ran on 32-bit Windows only. Since more and more (web) server applications are deployed on Unix machines, many customers contacted SAP about support for Unix. In response to these requests, JCo 1.1 now is also available for Linux, Solaris, AIX, and HP-UX.

Queued Remote Function Call (qRFC)

qRFC is relatively new in SAP, but it can be added to older SAP releases by applying a hot package. qRFC is basically an extension of transactional RFC (tRFC), and offers the following main additional features:

  • Within a queue, items are guaranteed to be processed in the specified order (serialization). This is true even if multiple processes are writing to a queue. With plain tRFC, we would not know the sequence in which the individual calls would be processed.
  • System administrators have full control over the queues, being able to specify when a queue should be activated. This allows processing of not-so-urgent input to be postponed until off-peak hours.

     JCo 1.0( already supported outbound qRFC (since there is no difference between tRFC and qRFC on the server side), i.e., you could write a server program that accepted qRFC messages from SAP. Now, in 1.1, inbound qRFC can be used as well. JCo offers the following, extended version of the execute() method:

public void execute(JCO.Function function,
                java.lang.String tid,
                java.lang.String queue_name)

     The tid parameter needs to be set to the Transaction ID (usually a GUID acquired via the createTID() method of the JCO.Client class1). The queue_name parameter is set to whatever queue name you have selected (or have been told to use). Here is some sample code for a qRFC inbound call:

JCO.Function function =
JCO.Table table =
table.setValue("Some test data", "LINE");
String tid = mConnection.createTID();
mConnection.execute(function, tid, "WBK");

     By the way: in most cases, you should consider qRFC instead of tRFC in your applications. Refer to SAP's documentation for more details on qRFC.

HTML Output

When debugging an application, it is often advantageous to be able to quickly check the parameters being passed to and from SAP. JCo offers method writeHTML() to create an HTML file based on an object of type JCO.Function, JCO.ParameterList, JCO.Structure, or JCO.Table. In JCo 1.0(, only the first 100 rows (and the last row) of a table would be included, which saved space (and prevented the browser from aborting due to a very large HTML file), but did not allow you to view all data. JCo 1.1 comes with a new global property, jco.html.table_max_rows, that can be used to control the maximum number of rows put into the HTML file. Here is some sample code:

JCO.Function function =
JCO.Table codes =
  function	.getTableParameterList()
	.getTable("COMPANY CODE_LIST");
String oldMaxRows = 
JCO.setProperty("jco.html.table_max_rows", "99999");
JCO.setProperty("jco.html.table_max_rows", oldMaxRows);

     Our code is polite enough to store the old value for the property before changing it. Then, after the call to writeHTML(), we restore the old value so that other users are not affected more than necessary (remember: the property is global within the Java Virtual Machine!). Figure 1 shows a screen shot of the beginning of the HTML page.

Figure 1 A Table Parameter Displayed in an HTML Page

XML Output and Input

In JCo 1.1, you can now create an XML representation of an object of type JCO.ParameterList, JCO.Structure, or JCO.Table by using method toXML(). Also, you can load data into a variable from an XML string by using method fromXML(). Here are the method signatures:

void fromXML(java.lang.String data) 
java.lang.String toXML() 
java.lang.String toXML(int index) 
java.lang.String toXML(java.lang.String field_name)

The following source code snippet demonstrates the toXML() method:

JCO.Structure returnStructure =
String xml = returnStructure.toXML();

Figure 2 shows you the XML string for the Return parameter of a successful BAPI call.

Figure 2 An XML String Representing the Return Parameter

Auto-Reset of Pooled Connections

There are two flavors of getClient(), the method used to retrieve a connection from a connection pool. Compare the following two lines of sample code:

     The second parameter of the second flavor of getClient() specifies whether the connection should be reset (equivalent to "/n" in SAPGUI). The first flavor uses a default of false. This is dangerous, since it assumes that all client programs using the pool are totally stateless.

JCO.Client mConnection = JCO.getClient("ARASOFT")
JCO.Client mConnection = JCO.getClient("ARASOFT". true);

     The only reason for the existence of the second parameter is that 3.1 does not support connection resetting via RFC. It was very easy to use this parameter incorrectly, though, and if you are running 4.0 or later you should definitely always use true (and hence never the first flavor of getClient()!).

     JCo 1.1 now automatically resets the connection (when it is returned to the pool) if you are connected to a 4.0 or later SAP system. This makes life easier for the application programmer using those versions of SAP. Only if you are still running R/3 3.1 do you still have to choose between speed (no reset of the connection, but everything needs to be stateless) and integrity (since 3.1 does not support reset, the connection is closed and re-opened when you set the second parameter to true).

Miscellaneous Enhancements

There are some additional enhancements, like support for complex data types (required if you want to interface with CRM), a new ServerErrorListener interface to build more stable server components, etc.

     For a complete list of all these enhancements, please refer to the Release Notes of JCo 1.1, included in the download.

Thomas G. Schuessler is the founder of ARAsoft (, a company offering products, consulting, custom development, and training to a worldwide base of customers. The company specializes in integration between SAP and non-SAP components and applications. ARAsoft offers various products for BAPI-enabled programs on the Windows and Java platforms. These products facilitate the development of desktop and Internet applications that communicate with R/3. Thomas is the author of SAP's CA925 "Developing BAPI-enabled Web Applications with Visual Basic" and CA926 "Developing BAPI-enabled Web Applications with Java" classes, which he teaches in Germany and in English-speaking countries. Thomas is a regularly featured speaker at SAP TechEd and SAPPHIRE conferences. Prior to founding ARAsoft in 1993, he worked with SAP AG and SAP America for seven years. Thomas can be contacted at or at

1 SAP has decided to spell "JCo" with a lower-case "o", but in Java source code you need to use "JCO" since Java is case-sensitive, hence the mixed spelling in this article.

An email has been sent to:

More from SAPinsider


Please log in to post a comment.

No comments have been submitted on this article. Be the first to comment!