+

Search Tips   |   Advanced Search

Call stub generator CSG.xml file

The CSG.xml file provides a complete example of how to start the COBOL call stub generator from Ant using the <csg> custom task or within Rational Application Developer as an Ant build.


CSG.xml input properties

The following table describes the CSG.xml input properties. If we run the <csg> task in the Rational Application Developer graphical interface, we can define the properties using the -Dproperty_name=property_value format.

Name Required or Optional Description
cobolSource Required Fully qualified path to the COBOL source file.

Avoid trouble: Use forward slashes (/), or remember to escape the back slashes (\\), in all path names.gotcha

In the Rational Application Developer graphical interface, we can use the ${resource_loc} built-in variable, which is substituted with the fully qualified path of the resource currently selected on the Package Explorer.

workSpace Required Fully qualified path to the root directory of the Rational Application Developer or Eclipse workspace to be used to create the Java data binding class.

In the Rational Application Developer graphical interface, we can use the ${workspace_loc} built-in variable, which is substituted with the fully qualified path of the current active workspace.

eclipseProjectName Required Name of the project in the Rational Application Developer or Eclipse workspace that provides the home for the generated Java class.

In the Rational Application Developer graphical interface, we can use the ${project_name} built-in variable, which is substituted with the project name of the resource currently selected on the Package Explorer.

The project must exist before running the call stub generator.

callStubPackage Required Package name to use for the generated call stub.

In the Rational Application Developer graphical interface, we can use the ${string_prompt:callStubPackage} built-in variable. At run time, Rational Application Developer prompts you for a string value. The title of the prompt dialog box is callStubPackage.


File location

The CSG.xml Ant build file has a location such as:


CSG.xml contents

The CSG.xml file provided with the product resembles the following example:

<?xml version="1.0" encoding="UTF-8"?>
<!-- ........................................................................... -->
<!-- This Ant build file is used for invoking the COBOLCallStubGenerator (CSG)       within Rational Application Developer. It has two steps:
     1. Calls CSG for the given cobolSource file.
        CSG is invoked using the custom <csg> task.           <csg> generates the Java call stub and the data binder Ant file.
     2. Invokes the data binder Ant file that is generated by <csg>.
        The data binder Ant file invokes the data binder and generates         the data binding Java classes for the COBOL parameters.
     To configure this file for use within Rational Application Developer:
     1. Run -> External Tools -> External Tools Configuration.
     2. New Ant Build
        Buildfile: full_path_to_this_file.xml
        Arguments: -DcobolSource=${resource_loc}                     -DworkSpace=${workspace_loc}                     -DeclipseProjectName=${project_name}                     -DcallStubPackage=${string_prompt:callStubPackage}
        Refresh: project         Build: project         JRE: same as workspace (needs J2C tools installed)
      Usage instructions:
     1. Load the COBOL source into the project.
     2. Select the COBOL source file or source directory in Project Explorer.
     3. Click Run -> External Tools -> CSG Ant build.                        -->
<!-- ........................................................................... -->
 <project default="CSG">
  <property name="csgDir" value="${basedir}" />
  <property name="debug" value="false" />
   <!-- Include the <csg> and <radlogcheck> task definitions -->
<taskdef resource="com/ibm/ws/batch/cobol/ant/callstub/antlib.xml"
         classpath="${csgDir}/lib/COBOLCallStubGenerator.jar"/>     <!-- These input properties are required.  They can be specified as arguments to the Ant build. -->
  <property name="cobolSource"        value="" />  <!-- full path to COBOL source file -->
  <property name="workSpace"          value="" />  <!-- full path to Eclipse workspace -->
  <property name="eclipseProjectName" value="" />
  <property name="callStubPackage"    value="" />
   <!-- The output from the <csg> task is the data binder Ant build file.  The data binder Ant
       build file invokes the data binder and generates the data binding classes for all        the COBOL parameters for all the COBOL files processed by <csg>.  -->
  <property name="antBuildFile" value="${workSpace}/${eclipseProjectName}/src/GenAllBindings.xml" />
   <!-- Quick way to get the directory of the input COBOL file, in case we wanted to use it        to specify a list of files in the <fileset> type.  -->
  <dirname property="cobolSourceDir" file="${cobolSource}" />
   <target name="CSG">
     <csg configFile="${csgDir}/csg.properties"           workSpace="${workSpace}"           eclipseProjectName="${eclipseProjectName}"           antBuildFile="${antBuildFile}" >
       <!-- In this example, the input is a single COBOL file, specified using a <fileset>.
           We can modify the input to be a list of COBOL files, using either the             <fileset> or <filelist> types.  For example, instead of using the cobolSource
           property, we can use the cobolSourceDir property to specify all *.cbl files            in the directory or use <filelist> to list a subset of files in the directory.             Examples for setting the input to a list of files are included here, but commented out.  -->
      <fileset file="${cobolSource}" />        <!-- Example: Set the input to all *.cbl files in a directory: -->
      <!-- <fileset dir="${cobolSourceDir}" includes="**/*.cbl" /> -->
      <!-- Example: Set the input to a subset of files in a directory: -->
      <!-- <filelist dir="${cobolSourceDir}" files="G10M0802.cbl primitve.ccp natltest.ccp" /> -->
      <!-- Example: Associate all the nested files with the specified <cobolModule>: -->
      <!-- <cobolModule libname="MyDLLName">
             <fileset dir="${cobolSourceDir}" includes="**/*.ccp" />             </cobolModule> -->
      <!-- We can specify multiple <cobolModule> elements. -->
       <callStubPackage>${callStubPackage}</callStubPackage>
      <!-- Example: We can use some internal call stub generator properties as substitution
           variables. For example, to include the COBOL PROGRAM-ID ($_ProgramId_$) in the          callStubPackage: -->
      <!-- <callStubPackage>${callStubPackage}.$_ProgramId_$</callStubPackage> -->
       <!-- If not defined, the package name for the data binding classes is             ${callStubPackage}.parameters. -->
      <!-- <dataElementsPackage>${callStubPackage}.parameters</dataElementsPackage> -->
       <!-- Example: Use substitution variables to prepend the COBOL PROGRAM-ID to the             parameter class name. -->
      <!-- <dataElementsClass>$_ProgramId_$_$_DataElementName_$</dataElementsClass> -->
       <!-- The Java package and class for the parameter identified by 'name' in COBOL             program 'programId' -->
      <!-- <dataElement name="#REQUIRED" programId="#REQUIRED" packageName="" className="" /> -->
      <!-- We can specify multiple <dataElement> elements. -->
     </csg>
     <!-- Refresh the workspace in order to compile the Java call stubs generated by <csg> -->
    <eclipse.refreshLocal depth="infinite" resource="${eclipseProjectName}" />
     <!-- radlogcheck first takes a snapshot of the Rational Application Developer log          (${workSpace}/.metadata/.log).  Later, radlogcheck examines the log and searches
         for any errors generated during this data binding step. -->
    <radlogcheck workSpace="${workSpace}" stage="begin"  />
     <!-- Now run the data binder Ant build file that is generated by the <csg> task. -->
    <ant antfile="${antBuildFile}" />
     <!-- Scan the log for any errors that occured during the data binding step.            If errors are detected, the product writes them to the console. -->
    <radlogcheck workSpace="${workSpace}" stage="end" />
     <!-- Delete the antBuildFile. It is no longer needed and is merely a build artifact. -->
    <delete file="${antBuildFile}" failonerror="false"/>     </target>
</project>


Related tasks

  • Generating COBOL call stubs
  • Invoking the call stub generator from an Ant task
  • Invoking the call stub generator from a graphical interface