You can use the COBOL call stub generator to create a Java call stub to invoke a COBOL
program. You add the call stub to a Java-based batch application.
Before you begin
Read the COBOL container overview topic.
Install
the following products, which are required to use the COBOL call stub
generator:
- IBM® Rational® Application Developer for WebSphere® Software, Version 7.5 or later,
which provides the J2EE Connector (J2C) tools
- Java Runtime Environment (JRE), Version 1.6.0 or later
To verify that the Java EE Connector (J2C) tools are enabled,
start Rational Application Developer, select the
Java EE perspective, and select .
If the J2C wizard is available, then you can
create a J2C project and the J2C tools are enabled.
If the Rational Application Developer installation does not
have the Java EE Connector (J2C) tools, use Installation Manager to
modify your Rational Application Developer installation
and install the J2C tools:
- Start Installation Manager.
- On the Modify Packages page, select .
- Complete the installation of the J2C tools.
About this task
You can run the COBOL call stub generator from a command
line, an Ant task, or the graphical interface of the Rational Application Developer product.
The
COBOL call stub generator performs the following steps:
- Parses the COBOL source program.
- Generates the Java code for the call stub to invoke the COBOL
program.
- Generates the Java code for the data bindings for the parameter
inputs and return value that are used by the COBOL program. The source
program is assumed to be a valid COBOL program that has been parsed
and compiled by a COBOL compiler.
The Java data binding classes for the COBOL parameters and
return value are generated by the J2C data binding tool, which is
part of the Java EE Connector tools of the Rational Application Developer
product. When you run the COBOL call stub generator from a command
line, the call stub generator and the data binding tool run in a headless
Eclipse session. The headless Eclipse session is launched as a separate
Java process. When you run the COBOL call stub generator from the
graphical interface, the call stub generator and the data binding
tool run within the active Rational Application Developer session.
Procedure
- Create a Rational Application Developer project
for the generated code.
- Check the PROCEDURE statement in the COBOL source file.
The PROCEDURE statement must be listed in the COBOL source
file, not in a copybook included by the source file. If the call stub
generator does not find the PROCEDURE statement in the COBOL source
file, the call stub generator fails with an error:
com.ibm.ws.batch.cobol.csgen.exceptions.COBOLParserException:
Unable to find PROCEDURE statement in file COBOL_source_file
Also,
the PROCEDURE statement must not contain duplicate parameter names
in the USING clause. If the USING clause contains a duplicate parameter
name, the call stub generator fails with an error:
com.ibm.ws.batch.cobol.csgen.exceptions.COBOLParserException:
Detected duplicate COBOLDataElement: parameter name
- Update the call stub generator configuration file.
See the topic about the call stub generator configuration
file.
- Run the COBOL call stub generator.
You can
run the call stub generator in three ways:
- From a command line
- Create a script that invokes the call stub generator.
- Run the script.
$ java –jar lib/COBOLCallStubGenerator.jar script_path/Sample01.cbl –configFile csg.properties –callStubPackage my.pkg
See the topic about invoking the call stub generator from
a command line.
- From an Ant program
- Define an Ant task that invokes the call stub generator.
- Specify an Ant build file, such as the CSG.xml file
that is provided with the COBOL call stub generator, to run the call
stub generator.
- Run the Ant build file.
See the topic about invoking the call stub generator from
an Ant task.
- From the Rational Application Developer graphical interface
- Configure an Ant build under the menu that invokes the call stub generator.
- Specify that Ant build file, such as CSG.xml,
run the call stub generator.
- Run the Ant build file.
See the topic about invoking the call stub generator from
a graphical interface.
Results
If the call stub generator invocation is successful, the
call stub generator creates a Java call stub to invoke a COBOL program.
With
a headless
Rational Application Developer invocation,
an error might result when the call stub generator runs. Running the
call stub generator from a command line or Ant task uses a headless
invocation. Examine the following logs to troubleshoot an error:
- workspace_path/.metadata/.log
- The log identifies whether problems with the Eclipse-based tools,
such as the headless invocation did not start, caused the error.
- user_home/.eclipse/ibm.software.delivery.platform_7.5.0/configuration
- Each headless invocation might create log files in the configuration directory.
If the log files exist, they might provide troubleshooting information
on the error.
What to do next
Use the generated Java call stub to invoke a COBOL program.