Previous Topic Next topic Print topic


Developing an application for multiple run units in Java

Note: The following applies to managed COBOL only.

You can use any existing COBOL program in a multiple user environment in Java. Do this as follows:

  1. Create a COBOL class library project and add your procedural COBOL program to that project.
  2. Rebuild the project.

Whether the COBOL program to be called is procedural or OO COBOL, you need a program to call it:

  1. Create a project for the calling program.
  2. In the calling program, create a run unit using the com.microfocus.cobol.runtimeservices.RunUnit constructor.
  3. Use the Try ... Finally syntax to ensure that the program destroys the run unit if the program fails.
  4. Either use the RunUnit.Call() method to call the COBOL class, or:
    • Make sure that any parameters are Java primitive data types.
    • Create an instance of the procedural COBOL program to be called.
    • Add the program instance to the new run unit, using the RunUnit.Add() method.
    • Invoke the program instance within the new run unit.
  5. Use the StopRun() method to destroy the run unit when you have finished with it.
Note:
  • If the run unit causes a run-time error, a java.lang.RuntimeException is thrown.
  • In OO COBOL programs in a mixed language environment, do not use static methods and data as they cause run-time errors.
  • Ensure that data access is synchronized, as the run units will be executing in different threads.

For details of the RunUnit class and further examples see the documentation about com.microfocus.cobol.runtimeservices - see the topic com.microfocus.cobol.runtimeservices.

Previous Topic Next topic Print topic