Core Business Programming Language
Part Two - Challenge #13


Imagine that a new programming language needs to be developed to handle the most critical data in the world economy. This language must be easy to learn, easy to maintain, easy to debug, and auditors need to be able to read and understand it. The programming language compiler needs to generate highly optimized code for processing speed. The language needs to be upwardly compatible for many years into the future to protect application programming investments, enhancements, and applied tuning. The programs should run with new releases of the operating system without need to change code or recompile.

Given these requirements, a COmmon Business-Oriented Language would most likely get developed. With the tech industry's propensity for acronyms, we might even give the programming language a short name like... "COBOL".

This is exactly what happened in 1959.

Due to the stability and importance of COBOL applications, they tend to be very long-lived. It is not rare to hear about business critical applications written in COBOL 10 to 30 years ago, still in production today.

Do not underestimate the significance of including COBOL on a resume. The core business logic of many large enterprises is written in COBOL and you can count on having COBOL on your resume grabbing the attention of many recruiters.

Your challenge:

  • Become familar with coding a COBOL program.
  • Compile and execute a z/OS COBOL program in batch.
  • Execute COBOL program interactively.
  • Debug and correct COBOL syntax problems.

Here's an example of a very basic COBOL program:


At this time, you will compile and execute the above COBOL program by submitting JCL. Execute the following command from any ISPF primary command line:


View the job output in SDSF: =SD ; ST

The first step in CC#####.JCL(SIMPLE) executes IGYWCL. This is a system provided 2-step procedure that runs the COBOL compile, reading the source code from CC#####.SOURCE(SIMPLE), then runs the link-edit, storing the executable load module in CC#####.LOAD(SIMPLE).

The second step in CC#####.JCL(SIMPLE) executes PGM=SIMPLE from CC#####.LOAD(SIMPLE).

It's also possible to execute COBOL programs in the foreground, which can be useful if the program requires user input. Perform the following actions:

  • Enter the ISPF primary command =6 to jump to the ISPF Command Shell panel.
  • Enter the command CALL LOAD(SIMPLE).

One of the first things you need to know about programming in COBOL is how to structure the code and what each piece of language comprises the overall grammar. Divisions may contain Sections which may contain Paragraphs which may contain Sentences which may contain Statements.

There are four Divisions in every COBOL program:

  1. Identification Division.
  2. Environment Division.
  3. Data Division.
  4. Procedure Division.

The Identification, Environment, and Data Divisions are used to declare the inputs, outputs, record field types and descriptions. The Procedure Division contains all of the execution logic instructions.

COBOL has a fixed format for each line in the source code. Each line has 72 columns and are sub-divided for specific purposes:

Columns Purpose
1 - 6 Sequence Numbering
7 Indicator Area
8 - 11 Area A
12 - 72 Area B

The Indicator area serves a few purposes, but the most common one being that if you place an asterisk * in column 7, this indicates that the line is a comment.

Area A is used to store all COBOL divisions, sections, paragraphs and some special entries.

Area B is used to store all COBOL statements.

Let's look at a COBOL that will read from a file and write to a file. Remember, abstract program filenames in z/OS can be linked to real resources via JCL DDNAME definitions.

View the data set CC######.SOURCE(CBLRDWR). Ensure you have turned on syntax highlighting with the editor command HILITE AUTO. While reviewing the CBLRDWR source code, return to the above information and see if you can locate the various components of syntax and grammar.

Take note of the filenames in the CBLRDWR source.

Jump to data set list utility panel =3.4 and view V CC######.JCL(CBLRDWR). Read the CBLRDWR JCL given the filenames coded in the COBOL program.

SUBMIT JCL(CBLRDWR), then jump to SDSF =SD ; ST to review the job's output. You may want to enter the SDSF command INPUT OFF to suppress unnecessary system generated DDNAMEs in the output such as JCLIN, $INTTEXT, and EVENTLOG.

Notice that the program failed to compile due to an error identified by message ID IGYPS2122-S in the job output. The text following the message ID explains the problem. You may also notice additional abnormal end (abend) error messages. Don't worry if you cannot understand the gibberish, just look for the messages that are spelled out in English. Once you've located the cause of the error, edit SOURCE(CBLRDWR) and correct the error, then submit JCL(CBLRDWR) to compile, link and execute again, then review the output in SDSF. Repeat this cycle as many times as is neccessary for the COMPILE step to complete successfully.

Once the program successfully compiles, note that the program execution fails. The execution failure is not due to a COBOL or JCL syntax error as that would be detected by system prior to execution.

The execution problem is related to one of the fundamental reasons JCL exists. We explained it previously. Review the output to identify the problem, then edit JCL(CBLRDWR) to correct the problem. Repeat this cycle as many times as is neccessary for the RUN step to complete successfully.

Successful execution will result in the creation of P2.OUTPUT(#13). Review it for accuracy and move on to the next challenge. Great job!

Next: Challenge #14