Generating COBOL code using Ant

You can use an Ant task to automate the generation of COBOL code from a ruleset archive.

About this task

Deprecated feature:

Deprecation icon The COBOL code generation feature is deprecated in V8.5. This feature will be removed in a future release of the product. Use the COBOL Generation Project Migration wizard to migrate your Rules for COBOL project to a zRule Execution Server for z/OS compatible rule project. See Deprecated features for migration details.

In a production environment, it is common to automate tasks using a build tool. Decision Server provides custom Ant tasks to automate COBOL code generation from a ruleset archive. You can use an Ant task to generate the COBOL code for rules that have been written in Rule Designer or Decision Center.

Procedure

To generate COBOL code using an Ant task:

  1. Before using an Ant task to generate the COBOL code, define the class path in an Ant file. The resource archives are stored in following directories:
    • <IBMIMSharedDir>\plugins\com.ibm.rules.zrules.zxom_8.10.0.vXX\lib\cobol-gen-shared.jar

    • <IBMIMSharedDir>\plugins\com.ibm.rules.zrules.zxom_8.10.0.vXX\lib\cobol-shared.jar

      Where <IBMIMSharedDir> is the shared libraries directory for IBM® Installation Manager, and vXX is the version number. Replace this variable with the actual version for your installation.

    • <InstallDir>\executionserver\lib\jdom-1.0.jar

    • <InstallDir>\executionserver\lib\jrules-engine.jar

    • <InstallDir>\executionserver\lib\jrules-language.jar

      Where <InstallDir> is the Operational Decision Manager installation directory.

  2. Define the custom Ant task in the Ant file, by including the following code:

    <taskdef resource="cblruletasks" classpathref="classpath" />

    This code defines the following Ant task for COBOL code generation:

    <gen-cobol rulesetfile="miniloanruleset.jar" 
    cobolprogId="miniloan" 
    cobolfile="miniloan.cbl" 
    codegenconfigfile="CobolGenConfig.xml">
    
    <refconfigfolder dir="referenceProject/resources/cobol " />
    </gen-cobol>
    

    The following table defines the attributes you can use for the gen-cobol Ant task:

    Attribute Required Description
    rulesetfile Yes The ruleset file that is targeted to generate the COBOL program.
    cobolprogId Yes The program ID of the generated COBOL program.
    cobolfile Yes The generated COBOL program file.
    codegenconfigfile Yes CobolGenConfig.xml: the configuration file for COBOL code generation.
    compileoptionsfile Optional

    CobolCompilerOptions.properties: the configuration file for the COBOL program file encoding and character code page.

    The default options are:

    • COBOL program file encoding: IBM-1252

    • Run time code page: IBM-037

    xomconfigfile Optional CobolXomConfig.xml: the configuration file for the COBOL XOM. It includes the COBOL copybook information. Required only for rule projects with a BOM created from a copybook.
    bomconfigfile Optional CobolBomConfig.xml: the configuration file for the COBOL-enabled BOM. Required only for rule projects with a COBOL-enabled BOM.
    enableCics Optional The flag to enable COBOL code generation for a CICS® program.
    cicsprogId Optional The program ID for the generated CICS wrapper program.
    cicsfile Optional The generated CICS wrapper program file

    The following table defines the element you can use for the gen-cobol Ant task:

    Element Required Description
    refconfigfolder Optional The resource folder for the configuration files for the referenced rule project. Used for COBOL rule projects that have a reference structure.
  3. Run the Ant task to generate the COBOL code.