+

Search Tips   |   Advanced Search

Generating COBOL call stubs

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.

Read the COBOL container overview topic.

Install the following products, which are required to use the COBOL call stub generator:

To verify that the Java EE Connector (J2C) tools are enabled, start Rational Application Developer, select the Java EE perspective, and select File > New > Other. If the J2C wizard is available, then we 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 the Rational Application Developer installation and install the J2C tools:

  1. Start Installation Manager.

  2. On the Modify Packages page, select IBM Rational Application Developer for WebSphere Software > J2EE Connector (J2C) tools > Next.

  3. Complete the installation of the J2C tools.

We 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:

  1. Parses the COBOL source program.

  2. Generates the Java code for the call stub to invoke the COBOL program.

  3. Generates the Java code for the data bindings for the parameter inputs and return value 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.

  1. Create a Rational Application Developer project for the generated code.

  2. 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

  3. Update the call stub generator configuration file.

    See the topic about the call stub generator configuration file.

  4. Run the COBOL call stub generator.

    We can run the call stub generator in three ways:

    From a command line

    1. Create a script that invokes the call stub generator.

    2. 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

    1. Define an Ant task that invokes the call stub generator.

    2. Specify an Ant build file, such as the CSG.xml file provided with the COBOL call stub generator, to run the call stub generator.

    3. 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

    1. Configure an Ant build under the Run > External Tools > External Tools Configuration menu that invokes the call stub generator.

    2. Specify that Ant build file, such as CSG.xml, run the call stub generator.

    3. 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.


Subtopics


Related concepts

  • COBOL container overview