Developing COBOL programs for CICS

You can write CICS® applications in COBOL and run them on a Linux® workstation using CICS TX or TXSeries. The cicstcl utility included with CICS TX and TXSeries performs the translation, compiles the translated program, and links the resulting object by invoking cob2 to do the compilation and link, passing in the -qcics option. We recommend to use the cicstcl utility to write CICS applications. Alternatively, you can directly use the cob2 or cob2_cics compiler command with the -qcics option. There is no difference in functionality between the two methods.

About this task

Notes:

To prepare COBOL applications to run under CICS, do these steps:

Procedure

  1. Ensure that your CICS administrator modified the region's environment file to set the environment variables COBPATH, LD_LIBRARY_PATH, and NLSPATH to include the runtime directory:
    export COBPATH=<dynamically accessed program dir>:$COBPATH
    export NLSPATH=<CICS install dir>/msg/%L/%N:$NLSPATH
    export LD_LIBRARY_PATH=<CICS install dir>/lib:$LD_LIBRARY_PATH
    Also, ensure that the CICS region was granted access to the runtime directory.

    The environment file is /var/cics_regions/xxxxxxxx/environment (where xxxxxxxx is the name of the region).

  2. Check your cob2.cfg file to ensure that any paths to your specific CICS version are set up correctly. Use of the cob2_cics command and corresponding cob2_cics stanza in the cob2.cfg file are recommended when developing COBOL programs for CICS. See Modifying the default compiler configuration for more information.
  3. Create the application by using an editor to do the following tasks:
    • Code your program using COBOL statements and CICS commands.
    • Create COBOL copybooks.
    • Create the CICS screen maps that your program uses.
  4. Use the command cicsmap to process the screen maps.
  5. Use the cicstcl command to translate the CICS commands with an integrated CICS translator and to compile and link the program. If you don't specify a file extension, cicstcl by default uses the COBOL source file extension .cbl.
    The following examples show how to use the cicstcl command to translate, compile, and link a sample COBOL program APPLCOB that runs under TXSeries® or CICS TX. The cicstcl command generates the output module with the .ibmcob extension.
    • To compile, translate, and link-edit a CICS COBOL application, use the -l IBMCOB option to specify the source language as IBM® COBOL, and the CICS COBOL program file extension can be .ccp or .cbl:
      cicstcl -l IBMCOB APPLCOB.ccp
      cicstcl -l IBMCOB APPLCOB.cbl
    • To compile, translate, and link-edit a CICS COBOL application to be used to debug using CEDF, use the -e option. To display CICS statement line numbers, use the -d option:
      cicstcl -e -l IBMCOB APPLCOB.cbl
      cicstcl -e -d -l IBMCOB APPLCOB.cbl
    • To compile, translate, and link-edit a CICS COBOL application to be used to debug, use the -a option:
      cicstcl -a -l IBMCOB APPLCOB.cbl
    • To compile, translate, and link-edit a CICS COBOL application by specifying the COPYBOOK path, set the SYSLIB environment variable to specify the directory of the COBOL source COPYBOOK path and then use the cicstcl command:
      export SYSLIB=”/program_copybook_path
      cicstcl -l IBMCOB APPLCOB.cbl
    • To compile, translate, and link-edit a CICS COBOL application by statically linking a COBOL module, set the USERLIB environment variable to specify the compiled object module path and then use the cicstcl command:
      export USERLIB=”cobol_module.o”
      cicstcl -l IBMCOB APPLCOB.cbl
    Note: If you want to compile and link a CICS COBOL program without using the cicstcl command, use the cob2 or cob2_cics compiler command with the -qcics option. There is no difference in functionality between the two methods. The following example shows how to compile and link a CICS COBOL application using the cob2 command:
    cob2 -qNOTHREAD -I/opt/ibm/cics/include -qcics -o APPLCOB.ibmcob APPLCOB.cbl -L/opt/ibm/cics/lib -lcicsprIBMCOB
    For detailed usage of the cicstcl command, see "cicstcl" in TXSeries for Multiplatforms documentation or "cicstcl" in CICS TX documentation.
  6. Define the resources for your application, such as transactions, application programs, and files, to the CICS region.
    CICS administrator authority is required to perform these actions.
  7. Access the CICS region, for example by using the cicsterm command.
  8. Run the application by entering the four-character transaction ID that is associated with the application.

What to do next

Related concepts  
Integrated CICS translator