Previous Topic Next topic Print topic


Using the cobcall() Methods

Restriction: This applies to native code only.

Once you have loaded the libraries or programs required by your Java application (see the previous section for details) you can make calls to COBOL using the cobcall_ methods. The cobcall_ methods are all static methods of RuntimeSystem.class, so you do not have to instantiate RuntimeSystem.class before starting. Each cobcall_ method takes two or three parameters (the third parameter is optional):

Style 1:

Style 2:

Parameters are converted between Java and COBOL data types as described in the chapter Java Data Types. As explained in the section Coding Your Java Program there are different cobcall_ methods, each named according to the Java equivalent of the data type returned by the COBOL program or entry being called. For example, a COBOL program that returns a signed integer (such as a pic s9(9) comp-5) is returning the Java data type int. So you would call the COBOL program using the cobcall_int method. By default all parameters are passed by reference.

The copybook javatypes.cpy also provides a set of COBOL type definitions for Java data types. We advise you to use the data types defined in this file to declare COBOL data items that are going to be used for passing parameters between Java and COBOL. Using these data types helps keep your code portable between different COBOL platforms.

See the Java Run-time Class Library Reference, which is in docs/mfcobol.docs.zip in your COBOL development system installation.

Previous Topic Next topic Print topic