Preparing COBOL programs in Windows

Use this information to learn to prepare COBOL programs in Windows, and preparing CICS and Transaction Server programs.

  1. The 32 bit COBOL copy books are installed in the following directory: MQ_INSTALLATION_PATH \Tools\cobol\CopyBook.
  2. The 64 bit COBOL copy books are installed in the following directory: MQ_INSTALLATION_PATH \Tools\cobol\CopyBook64
  3. In the following examples set CopyBook to:
    CopyBook
    
    for 32 bit applications, and:
    CopyBook64
    
    for 64 bit applications.

MQ_INSTALLATION_PATH represents the high-level directory in which IBM MQ is installed.

To prepare COBOL programs on Windows systems, link your program to one of the following libraries provided by IBM MQ:

Library file Program or exit type
MQ_INSTALLATION_PATH \Tools\Lib\mqmcbb 32 bit server for IBM COBOL
MQ_INSTALLATION_PATH \Tools\Lib\mqmcb 32 bit server for Micro Focus COBOL
MQ_INSTALLATION_PATH \Tools\Lib\mqiccbb 32 bit client for IBM COBOL
MQ_INSTALLATION_PATH \Tools\Lib\mqiccb 32 bit client for Micro Focus COBOL
MQ_INSTALLATION_PATH \Tools\Lib64\mqmcbb 64 bit server for IBM COBOL
MQ_INSTALLATION_PATH \Tools\Lib64\mqmcb 64 bit server for Micro Focus COBOL
MQ_INSTALLATION_PATH \Tools\Lib64\mqiccbb 64 bit client for IBM COBOL
MQ_INSTALLATION_PATH \Tools\Lib64\mqiccb 64 bit client for Micro Focus COBOL

When we are running a program in the MQI client environment, ensure that the DOSCALLS library appears before any COBOL or IBM MQ library.

We can use the IBM COBOL Set compiler or Micro Focus COBOL compiler depending on the program:

  • Programs beginning amqi are suitable for the IBM COBOL Set compiler,
  • Programs beginning amqm are suitable for the Micro Focus COBOL compiler, and
  • Programs beginning amq0 are suitable for either compiler.


IBM and Micro Focus COBOL

Relink any existing 32 bit IBM MQ Micro Focus COBOL programs using either mqmcb.lib or mqiccb.lib, rather than the mqmcbb and mqiccbb libraries.

To compile, for example, the sample program amq0put0, using IBM VisualAge COBOL:
  1. Set the SYSLIB environment variable to include the path to the IBM MQ VisualAge COBOL copybooks (enter the following code on one line):
      set SYSLIB= MQ_INSTALLATION_PATH\
      Tools\Cobol\Copybook\VAcobol;%SYSLIB%
    
  2. For use on the IBM MQ server:
      cob2 amq0put0.cbl -qlib " MQ_INSTALLATION_PATH\
      Tools\Lib\mqmcbb.lib"
    
  3. For use on the IBM MQ client:
      cob2 amq0put0.cbl -qlib " MQ_INSTALLATION_PATH\
      Tools\Lib\mqiccbb.lib"
    
    Note: Although we must use the compiler option CALLINT(SYSTEM), this is the default for cob2.

To compile, for example, the sample program amq0put0, using Micro Focus COBOL:

  1. Set the COBCPY environment variable to point to the IBM MQ COBOL copybooks (enter the following code on one line):
      set COBCPY= MQ_INSTALLATION_PATH\
      Tools\Cobol\Copybook
    
  2. Compile the program to give you an object file:
      cobol amq0put0 LITLINK
    
  3. Link the object file to the run time system.

    • Set the LIB environment variable to point to the compiler COBOL libraries.
    • Link the object file for use on the IBM MQ server:
        cbllink amq0put0.obj mqmcb.lib
      
    • Or link the object file for use on the IBM MQ client:
        cbllink amq0put0.obj mqiccb.lib
      


Preparing CICS and Transaction Server programs

To compile and link a TXSeries for Windows NT, V5.1 program using IBM VisualAge COBOL:
  1. Set the environment variable (enter the following code on one line):
    set CICS_IBMCOB_FLAGS= MQ_INSTALLATION_PATH\
    Cobol\Copybook\VAcobol;%CICS_IBMCOB_FLAGS%
    
  2. Set the USERLIB environment variable:
      set USERLIB=MQMCBB.LIB
    
  3. Translate, compile, and link your program:
    cicstcl -l IBMCOB myprog.ccp
    

This is described in the Transaction Server for Windows NT, V4 Application Programming Guide. To compile and link a CICS for Windows V5 program using Micro Focus COBOL:

  • Set the INCLUDE variable:
    set
    INCLUDE=drive:\programname\ibm\websphere\tools\c\include;
            drive:\opt\cics\include;%INCLUDE%
    
  • Set the COBCPY environment variable:
    setCOBCPY=drive:\programname\ibm\websphere\tools\cobol\copybook;
               drive:\opt\cics\include
    
  • Set the COBOL options:

    • set
    • COBOPTS=/LITLINK /NOTRUNC

and run the following code:

cicstran cicsmq00.ccp
cobol cicsmq00.cbl /LITLINK /NOTRUNC
cbllink -D -Mcicsmq00 -Ocicsmq00.cbmfnt cicsmq00.obj
%CICSLIB%\cicsprCBMFNT.lib user32.lib msvcrt.lib kernel32.lib mqmcb.lib
Parent topic: Building your procedural application on Windows