Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

COBOL  Module 12 – Mainframe batch concepts: data sets, JCL and compilation (IBM z/OS)

Compiling, link-editing and utility steps

Read IBM's IGYWC, IGYWCL and IGYWCLG procedures, rebuild with cobc, see how TRUNC and SSRANGE change results, and know the utility steps of a batch job.

  • Intermediate
  • 15 minutes
  • Examples run with GnuCOBOL 3.2, Python 3.14.8 and Pyodide 314.0.7
  • By MySmartCoPilot
Free core, Pro depth: 6 of 15 minutes free
Free: Compiling and link-editing are two steps of IBM's procedures · cobc does the same two steps on this computer · Utility steps create, copy, sort and catalog the data sets · Practise: builds, return codes and utilities. With a pass: 2 in-depth parts and 3 interview answers, about 9 minutes.

What you will learn

  • Read IBM's compile and link-edit procedures and the data sets and return codes of each step
  • Map the steps of a z/OS build to cobc commands and flags for local work
  • Explain how TRUNC and SSRANGE change a program's results, and reproduce both with cobc
  • Predict what an IEFBR14, IEBGENER, sort or IDCAMS step does from its DD statements and control statements

Before you start

What you’ll learn · Before you start

What you will learn

  • Read IBM's compile and link-edit procedures and the data sets and return codes of each step
  • Map the steps of a z/OS build to cobc commands and flags for local work
  • Explain how TRUNC and SSRANGE change a program's results, and reproduce both with cobc
  • Predict what an IEFBR14, IEBGENER, sort or IDCAMS step does from its DD statements and control statements

Before you start

On this page

One changed COBOL program reaches production through two programs before it runs: the compiler, IGYCRCTL, and the binder, IEWBLINK. IBM ships three procedures for the trip, and a compile that ends with return code 8 still reaches the binder under the procedure’s default test.

This lesson reads the procedures for compiling and link-editing step by step, runs the same build with cobc, and then names the utility steps that create, copy, sort and catalog the data sets around a batch program.

Compiling turns the source into an object module: What a compile produces: the program's machine code with its calls to other programs still unresolved. The binder combines object modules into a program the system can load.; link-editing turns object modules into a program the system can load. IBM’s cataloged procedures package the steps: IGYWC compiles, IGYWCL compiles and link-edits, and IGYWCLG also runs the result. In IGYWCL the COBOL step runs IGYCRCTL, and the caller supplies COBOL.SYSIN with the source and COBOL.SYSLIB with the copybook libraries. The object goes to the temporary data set &&LOADSET through SYSLIN, and the LKED step’s binder: The z/OS program that link-edits object modules into a program stored in a load library, resolving the calls between them; IBM's COBOL procedures run it as IEWBLINK in their LKED step. writes the program to SYSLMOD, a PDSE: A partitioned data set extended: a library like a PDS whose directory grows as needed and whose freed space is reused without a compress. COBOL 6 executables must be stored in one. More in “z/OS data sets, catalogs and GDGs”:

compile-procedures.jcl: concept listing, not run JCL · compile-procedures.jcl
//BLDSHOW  JOB (ACCT),'BUILD SHOWACCT',CLASS=A,MSGCLASS=X
//* Concept listing, not run: compiles SHOWACCT and link-edits it
//* into the load library with IBM's procedure IGYWCL.
//BUILD    EXEC IGYWCL,PGMLIB='BANK.PROD.LOAD',GOPGM=SHOWACCT,
//            PARM.COBOL='SSRANGE,LIST,MAP'
//COBOL.SYSIN  DD DISP=SHR,DSN=BANK.PROD.COBOL(SHOWACCT)
//COBOL.SYSLIB DD DISP=SHR,DSN=BANK.PROD.COPYLIB

The compiler’s return code says how bad its messages were, and the procedure tests it:

Level Return code IBM’s meaning
I, W 0, 4 information, a possible error
E 8 an error the compiler tried to correct
S 12 a serious error it could not correct
U 16 the compile was ended

LKED says COND=(8,LT,COBOL), so it is bypassed only after a compile return code of 12 or 16. A program with E-level errors is link-edited and, in IGYWCLG, run, although IBM says its results might not be what you expect. Step through IGYWCLG:

Interactive · stage by stage IGYWCLG, from source member to running program Step down the column. Each step reads what the one before it wrote, and two COND tests guard the later steps.
IGYWCLG, from source member to running program, step 7 of 7. Showing COBOL step, Object in &&LOADSET, LKED step, Program in SYSLMOD, GO step, The job ends. In focus: The job ends.RC over 8: both skippedCOBOL stepPGM=IGYCRCTL, the compilerObject in &&LOADSETSYSLIN, passed onLKED stepPGM=IEWBLINK, the binderProgram in SYSLMODa PDSE, DSNTYPE=LIBRARYGO stepPGM=*.LKED.SYSLMODThe job endsevery step's code logged

The drawing shows the whole scene; its 7 steps are listed below.

Every step as text
  1. Compile. The COBOL step runs IGYCRCTL. The caller supplies COBOL.SYSIN with the source and COBOL.SYSLIB with the copybook libraries; the listing goes to SYSPRINT.
  2. The object module. The compiler writes an object module to the temporary data set &&LOADSET through SYSLIN, with DISP=(MOD,PASS), so the next step can read it.
  3. The first COND. LKED says COND=(8,LT,COBOL). It is bypassed when 8 is less than the compiler's return code, that is after 12 or 16, and GO with it, so a compile with only E-level errors, return code 8, is still link-edited.
  4. Link-edit. The binder IEWBLINK reads the object from SYSLIN, resolves calls from the Language Environment libraries in SYSLIB and writes the program to SYSLMOD.
  5. A program object. SYSLMOD is a PDSE, DSNTYPE=LIBRARY, because COBOL 6 executables must reside in a PDSE. The member name comes from the symbol GOPGM.
  6. Run. GO runs the program the binder just stored, unless COND=((8,LT,COBOL),(4,LT,LKED)) is true, after a compile return code over 8 or a link-edit one over 4.
  7. The job log. The job ends after GO, or after the compile when both later steps were bypassed. Its log lists each step with its condition code, which is the first thing to read before trusting the program.

Taking a link-edited program for a clean compile

A program in the load library proves only that the compile ended with 8 or less. Read the compiler’s return code in the job log, and treat 8 as a failed build unless your shop’s procedure tests for less.

cobc does the same two steps on this computer

Locally, cobc -c compiles to an object file, as IGYWC does, and cobc -x with the objects link-edits them into one program, as IGYWCL does. -I plays SYSLIB for copybooks and -t writes the listing that SYSPRINT holds on z/OS. The build of ACCTLIST and its subprogram SHOWACCT, then a compile with the copybook library left out:

Compile with a listing, link-edit, run, and a missing SYSLIB Python · build_session.py
from session import files, run

# The build of ACCTLIST and SHOWACCT with cobc, step by step as IBM's procedures do it on z/OS: a compile that writes
# an object file and a listing, with the copybook library in the place of SYSLIB; a link of the two into one program;
# a run; and a compile with the copybook library left out.
files("acctlist.cob", "showacct.cob", "copylib/ACCTREC.cpy")
run("""
cobc -std=ibm -c -I copylib -t showacct.lst -fno-theaders showacct.cob
ls
cat showacct.lst
cobc -std=ibm -x -I copylib acctlist.cob showacct.o
./acctlist
!cobc -std=ibm -c acctlist.cob
""")

Output

$ cobc -std=ibm -c -I copylib -t showacct.lst -fno-theaders showacct.cob
$ ls
acctlist.cob
copylib
showacct.cob
showacct.lst
showacct.o
$ cat showacct.lst

000001         IDENTIFICATION DIVISION.
000002         PROGRAM-ID. SHOWACCT.
000003        * A subprogram: shows the account record it is passed.
000004         DATA DIVISION.
000005         LINKAGE SECTION.
000006         COPY ACCTREC.
000001C       * ACCTREC: one account, as the account file holds it.
000002C        01  ACCT-REC.
000003C            05  ACCT-ID             PIC X(6).
000004C            05  ACCT-BRANCH         PIC X(3).
000005C            05  ACCT-BALANCE        PIC S9(9)V99 COMP-3.
000007         PROCEDURE DIVISION USING ACCT-REC.
000008             DISPLAY "SHOWACCT: " ACCT-ID " " ACCT-BRANCH " "
000009                 ACCT-BALANCE
000010             GOBACK.


0 warnings in compilation group
0 errors in compilation group
$ cobc -std=ibm -x -I copylib acctlist.cob showacct.o
$ ./acctlist
SHOWACCT: AC0001 MUM +00000250075
$ cobc -std=ibm -c acctlist.cob
acctlist.cob:7: error: ACCTREC: No such file or directory
    5 |        DATA DIVISION.
    6 |        WORKING-STORAGE SECTION.
    7 >        COPY ACCTREC.
    8 |        PROCEDURE DIVISION.
    9 |            MOVE "AC0001" TO ACCT-ID
acctlist.cob:9: error: 'ACCT-ID' is not defined
    7 |        COPY ACCTREC.
    8 |        PROCEDURE DIVISION.
    9 >            MOVE "AC0001" TO ACCT-ID
   10 |            MOVE "MUM" TO ACCT-BRANCH
   11 |            MOVE 2500.75 TO ACCT-BALANCE
acctlist.cob:10: error: 'ACCT-BRANCH' is not defined
    8 |        PROCEDURE DIVISION.
    9 |            MOVE "AC0001" TO ACCT-ID
   10 >            MOVE "MUM" TO ACCT-BRANCH
   11 |            MOVE 2500.75 TO ACCT-BALANCE
   12 |            CALL "SHOWACCT" USING ACCT-REC
acctlist.cob:11: error: 'ACCT-BALANCE' is not defined
    9 |            MOVE "AC0001" TO ACCT-ID
   10 |            MOVE "MUM" TO ACCT-BRANCH
   11 >            MOVE 2500.75 TO ACCT-BALANCE
   12 |            CALL "SHOWACCT" USING ACCT-REC
   13 |            GOBACK.
acctlist.cob:12: error: 'ACCT-REC' is not defined
   10 |            MOVE "MUM" TO ACCT-BRANCH
   11 |            MOVE 2500.75 TO ACCT-BALANCE
   12 >            CALL "SHOWACCT" USING ACCT-REC
   13 |            GOBACK.
   14 | <EOF>
[exit status 1]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 build_session.py

The listing shows COPY ACCTREC expanded line by line, marked C. Without -I copylib one missing copybook made five errors and exit status 1, the local counterpart of a severe compile. On z/OS, compiler options come from the installation defaults, the PARM of the compile step’s EXEC statement and PROCESS or CBL statements in the source; IBM ranks the source statements above the PARM. Locally they are cobc flags, and two compiler option: A setting such as TRUNC or SSRANGE that changes how the compiler builds a program. On z/OS it comes from the installation defaults, the compile step's PARM or a PROCESS statement in the source. change results:

  • TRUNC decides how a binary item is cut when a value has more digits than its PICTURE. A z/OS build and a local build with different TRUNC settings can print different numbers from the same program and data.
  • SSRANGE adds checks that stop a subscript or reference outside a table or a field. A program built without SSRANGE carries on past such a reference without a message.

Checkpoint

Check: IGYWC, IGYWCL, IGYWCLG and compiler return codes · The same build with cobc

  1. Question 1 of 2 A compile under IGYWCL ends with return code 8. What happens in the LKED step, whose EXEC says COND=(8,LT,COBOL)?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: It runs, because 8 is not less than 8

    COND=(8,LT,COBOL) bypasses the link-edit after a severe or unrecoverable compile, 12 or 16. A program compiled with E-level errors is link-edited, and IBM warns that its results might not be what you expect.

  2. Question 2 of 2 cobc -std=ibm -c acctlist.cob failed with ACCTREC: No such file or directory. Which part of a z/OS compile step does the missing cobc flag stand for?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: COBOL.SYSLIB, the copybook libraries, which -I copylib supplies

    COPY looks for its copybook in the libraries the compile is given: SYSLIB on z/OS, the -I folders locally.

Utility steps create, copy, sort and catalog the data sets

Many jobs have utility steps around their COBOL steps, and four IBM programs cover the common work:

Utility What the step does
IEFBR14 nothing itself; its DD statements create or delete data sets
IEBGENER copies a sequential data set or a member
SORT sorts the records of SORTIN into SORTOUT by the fields its SORT statement names
IDCAMS defines, lists, loads and deletes VSAM data sets and catalog entries

Utility steps take their orders from DD statements and control statements, not from code, so reading a job means reading those statements. Choosing one is choosing by the work: IEFBR14 to create or delete, IEBGENER to copy, the sort to put records in order, and IDCAMS for VSAM data sets and the catalog.

Checkpoint

Check: The four utility programs

  1. One question Step NEWFILE runs PGM=IEFBR14 with one DD statement, which names a new data set with SPACE and a DISP that catalogs it. What exists after the step?

    Choose one answer.

    Show the answer: One question

    Answer: The new data set, empty and cataloged

    Utility steps work through their DD statements and control statements. IEFBR14 reads no control statements at all, so the DD statements are the whole step.

Practise: builds, return codes and utilities

These questions use IGYWCL, the build session and the four utility programs.

Practice that adapts to you

Practise this lesson

6 questions about 6 ideas of this lesson. Each answer is explained at once, and what you get right is kept in this browser.

  1. Question 1 of 6 Which procedure compiles a program and link-edits it, without running it?

    Choose one answer.

    Show the answer: Question 1 of 6

    Answer: IGYWCL

    C for compile, L for link-edit, G for go: the letters after IGYW name the steps.

  2. Question 2 of 6 Under IGYWCLG, a compile ends with 8 and the link-edit with 0. Does the GO step run, with COND=((8,LT,COBOL),(4,LT,LKED))?

    Choose one answer.

    Show the answer: Question 2 of 6

    Answer: Yes, because neither 8 < 8 nor 4 < 0 is true

    Return code 8 passes both COND tests of the procedure, so read the compile's return code yourself before trusting a run.

  3. Question 3 of 6 Which cobc command does what IGYWC does?

    Choose one answer.

    Show the answer: Question 3 of 6

    Answer: cobc -c, which compiles to an object file without linking

    cobc -c compiles, cobc -x compiles and links, -I names copybook folders and -t writes the listing.

  4. Question 4 of 6 In showacct.lst, what do the lines numbered 000001C to 000005C after COPY ACCTREC show?

    Choose one answer.

    Show the answer: Question 4 of 6

    Answer: The copybook's lines, as the compiler read them in place of the COPY statement

    A listing is the place to see what COPY really brought in, which is how a wrong copybook version is found.

  5. Question 5 of 6 What does the program IEFBR14 itself do?

    Choose one answer.

    Show the answer: Question 5 of 6

    Answer: Nothing but return 0; the DD statements of its step create or delete data sets

    IEFBR14 is a step that exists so that its DD statements can be processed.

  6. Question 6 of 6 A job must put the posted records in order of branch and amount before a report step. Which utility step does it run?

    Choose one answer.

    Show the answer: Question 6 of 6

    Answer: The sort, with SORTIN, SORTOUT and a SORT statement naming the fields

    Choose the utility by the work: create or delete with IEFBR14, copy with IEBGENER, order with the sort, VSAM and catalogs with IDCAMS.

Compiler options that change results, reproduced with cobc Pro: opens with a Pro, Premium or Ultimate pass

Two programs give different answers under different compiler options, and both are IBM’s own cases. This part reproduces them with cobc, finds the cobc flags that match IBM’s defaults, and lists the defaults to read in every compiler listing.

In this part:

  • TRUNC: IBM’s two examples, three builds
  • SSRANGE: a subscript past the table, silent and caught
  • The defaults to read in every compiler listing
  • Which setting wins when an option is set in three places
  • A drill with sample tests
  • Predict a binary item after a MOVE under TRUNC(STD) and TRUNC(BIN)
    • Results of the sample tests

3 runnable examples (COB, Python) · 1 exercise with sample tests · about 7 minutes

Opening this part with your pass…

This part opens with any MySmartCoPilot pass.

  • Pro pass · 1 week₹79$2.99
  • 30 days₹179$5.99
  • 1 year₹1,699$45

One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

Utility steps line by line: IEFBR14, IEBGENER, the sort and IDCAMS Pro: opens with a Pro, Premium or Ultimate pass

Utility steps fail in ways a COBOL program never does, because their orders are in DD and control statements. This part reads the four steps of utilities.jcl, checks a sort statement against sample records, and shows the one DISP that lets a clean-up step work whether or not its data set exists.

In this part:

  • IEFBR14 does nothing, and its DD statements do the work
  • IEBGENER copies with four DD statements
  • A sort statement checked before the job runs
  • IDCAMS for VSAM data sets and the catalog

1 diagram · 2 runnable examples (JCL, Python) · about 5 minutes

Opening this part with your pass…Pro part. It opens with the same pass as the part above.

Interview questions

A warm-up answered in full, then three questions about builds and utility steps that misled their owners:

  1. Fresher to mid · Warm-up

    What do IBM's procedures IGYWC, IGYWCL and IGYWCLG do, and what must a job that calls them supply?

    They are IBM's cataloged procedures for Enterprise COBOL. IGYWC compiles only: its COBOL step runs the compiler, IGYCRCTL, and writes an object module. IGYWCL adds an LKED step in which the binder, IEWBLINK, link-edits the object into a program in the load library that SYSLMOD names, a PDSE for COBOL 6. IGYWCLG adds a GO step that runs the new program. The caller supplies COBOL.SYSIN with the source and COBOL.SYSLIB with the copybook libraries, and for IGYWCLG the DD statements the program itself needs, such as GO.TXNIN. LKED is bypassed only when the compile return code is over 8, so a compile with E-level errors is still link-edited.

  2. Mid to senior

    A change to a posting program compiled with return code 8 under IGYWCL. The load module was promoted, and in production the program produced wrong totals. How did it get through, what do you check first, and how do you stop builds like it?

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page. First step and follow-ups

  3. Mid to senior

    Unit tests built with cobc -std=ibm pass on developers' laptops. On z/OS, built with the shop's defaults, a PIC S9(4) COMP counter that received 12345 holds 2345, while the laptop build kept 12345. Explain the difference and make the two builds agree.

    Model answer, Pro. First step and follow-ups

  4. Fresher to mid

    A sort step with SORT FIELDS=(1,3,CH,A,14,9,ZD,D) put the posted records in branch and amount order for years. After the posted file was changed from FB to VB, the step still ends with return code 0, but the order looks random. What happened, and how do you fix and check it?

    Model answer, Pro. First step and follow-ups

Organisations named on this page

IBM’s Enterprise COBOL, z/OS and DFSORT manuals describe the procedures, options and utilities on this page; the builds ran with GnuCOBOL 3.2 and the sort check with Python. MySmartCoPilot belongs to neither IBM nor the GnuCOBOL project.

Flashcards · 8 cards

Recall it, then check

Say the answer to yourself before you look: recalling it is what makes it stick.

  1. What do IBM's procedures IGYWC, IGYWCL and IGYWCLG do?

    IGYWC compiles, IGYWCL compiles and link-edits, and IGYWCLG also runs the result. The caller supplies COBOL.SYSIN with the source and COBOL.SYSLIB with the copybook libraries.

  2. What are IGYCRCTL and IEWBLINK?

    The Enterprise COBOL compiler, which turns source into an object module, and the binder, which link-edits object modules into a program the system can load, written to a PDSE.

  3. What do compiler return codes 4, 8, 12 and 16 mean?

    4: W-level, a possible error. 8: E-level, an error the compiler tried to correct. 12: S-level, a serious error it could not correct. 16: U-level, the compile was ended.

  4. Why can a program with E-level errors reach the load library?

    The LKED step's COND=(8,LT,COBOL) bypasses the link-edit only after a compile return code of 12 or 16, so a compile that ends with 8 is still link-edited. Read the compiler's return code.

  5. Which cobc options play the parts of the z/OS compile and link steps?

    cobc -c compiles to an object file, cobc -x links objects into one program, -I plays SYSLIB for copybooks, and -t writes the listing that SYSPRINT holds on z/OS.

  6. Where does an Enterprise COBOL compile take its options from?

    The installation defaults, the PARM of the compile step's EXEC statement, and PROCESS or CBL statements in the source, which rank above the PARM.

  7. What do IEFBR14, IEBGENER, SORT and IDCAMS do?

    IEFBR14 does nothing itself, so its DD statements create or delete data sets. IEBGENER copies a sequential data set or a member. SORT orders SORTIN into SORTOUT. IDCAMS manages VSAM data sets and catalog entries.

  8. Why do TRUNC and SSRANGE matter when a z/OS build and a local build are compared?

    TRUNC decides how a binary item is cut when a value outgrows its PICTURE, so different settings can print different numbers. SSRANGE adds checks that stop a reference outside a table or a field.

Key takeaways

  • IGYWC compiles, IGYWCL also link-edits and IGYWCLG also runs; the caller supplies SYSIN and SYSLIB, and the link-edit is bypassed only after a compile return code over 8.
  • cobc -c compiles and cobc -x links, -I plays SYSLIB and -t writes the listing; z/OS takes options from defaults, the EXEC PARM and PROCESS or CBL statements.
  • IEFBR14, IEBGENER, SORT and IDCAMS do their work through DD and control statements.

Terms in this lesson

binder
The z/OS program that link-edits object modules into a program stored in a load library, resolving the calls between them; IBM's COBOL procedures run it as IEWBLINK in their LKED step.
compiler option
A setting such as TRUNC or SSRANGE that changes how the compiler builds a program. On z/OS it comes from the installation defaults, the compile step's PARM or a PROCESS statement in the source.
object module
What a compile produces: the program's machine code with its calls to other programs still unresolved. The binder combines object modules into a program the system can load.

References

Related tools

Report a problem with this lesson

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.