Hello World Program

As explained earlier, COBOL programs are two types based on the environment they are running -

  • Batch program (COBOL)
  • Online program (COBOL + CICS)

In this topic, we will see how to run a COBOL program in the batch environment.

How to run a COBOL program in a batch environment?

Prerequisites -

Below are the prerequisites to run a COBOL program in a mainframe environment -

  • A mainframe id.
  • A PDS (SRCLIB or Source Library with a record length of 80) is used to code the COBOL program.
  • A PDS (LOADLIB or LOAD Library with record length 80, block size 6144) for placing the LOAD module of the program after compilation.
  • [Optional, if required] A PDS ( calls as a COPYLIB with record length 80) to place external copybooks if used in the program.

Process Steps -

Below are the steps to run the COBOL program in a mainframe environment -

  • Code the program
  • Compile program
  • Run program

Code the program -

Login to the mainframe TSO environment, edit the PDS, and code the program like below -

Hello World Program

In this example, MATEGJ.COBOL.SRCLIB is the source library used to code the program and the program name is FIRSTPRG.

Note! The module name and program name with PROGRAM-ID should not be the same. However, to avoid confusion, specify both names as one. Refer to the screenshot below. Hello World Program

Compile program -

There are many ways to compile the COBOL program. Version control tools like Endevor or Changeman are used to compile the COBOL program in a real-time environment.

Also, we can use standard JCL to compile the program. The compile JCL for the COBOL program is as follows -

Compile JCL Screenshot -

COBOL program compilation JCL

COBOL compile JCL has two steps -

  • Compile step (IGYCRCTL - compilation utility) - Compilation utility to verify the syntax errors in the COBOL program. If syntax errors exist, the JCL fails with MAXCC > 4 (8, 12, 16). If there are no errors (MAXCC = 0 or 4), it creates the object code from the source code and passes it to the next step (link edit step).
  • Linkedit step (IEWBLINK - linkedit utility) - Link editor used to linkedit the module from the IGYCRCTL step and create the executable load module from the object code.

However, we should know the library name where the compilation utilities IGYCRCTL and IEWBLINK are placed. For Example - IGY420.SIGYCOMP for IGYCRCTL and CEE.SCEELKED for IEWBLINK in the above JCL.

Modify the highlighted libraries to their corresponding libraries and submit the JCL to compile the program.

Submit JCL

Once the MAXCC is 00(without warning or errors) or 04(with warnings), the COBOL program is compiled successfully.

Submit JCL Return Code

Executing program -

Submit the below JCL by changing the program name and the load library to execute the program -

RUN JCL Screenshot -



RUN JCL Submit

Once the MAXCC is 00(without warning or errors) or 04(with warnings), the COBOL program runs successfully.

RUN JCL Return Code

Check the output in SYSOUT of the SPOOL -

Program Output