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.
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 and link-editing are two steps of IBM’s procedures
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”:
//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:
The drawing shows the whole scene; its 7 steps are listed below.
Every step as text
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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:
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
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
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.
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.
Passes can’t be bought right now, so this part can’t be opened at the moment. The free part above stands on its own. If you have a pass, enter your licence key.
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:
-
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.
-
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?
-
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.
-
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?
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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
- Enterprise COBOL for z/OS 6.5 Programming Guide: Compile procedure (IGYWC) (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: Compile and link-edit procedure (IGYWCL) (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: Compile, link-edit, and run procedure (IGYWCLG) (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: Severity codes for compiler diagnostic messages (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: Specifying compiler options under z/OS (IBM)
- Enterprise COBOL for z/OS 6.5: Why does COBOL 6 use PDSEs for executables? (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: TRUNC (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: SSRANGE (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: NUMPROC (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: ARITH (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: OPTIMIZE (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: DYNAM (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: CODEPAGE (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: ARCH (IBM)
- Enterprise COBOL for z/OS 6.5 Programming Guide: NUMCHECK (IBM)
- z/OS Basic Skills: IEFBR14 utility, do (almost) nothing (IBM)
- z/OS Basic Skills: IEBGENER utility, generate and copy a sequential data set (IBM)
- z/OS Basic Skills: IDCAMS, use access method services for catalogs (IBM)
- z/OS 3.2 DFSORT Application Programming Guide: SORT control statement (IBM)
- z/OS 3.2 DFSORT Application Programming Guide: Program DD statements (IBM)
- z/OS 3.2 MVS System Messages: IEF212I (IBM)
- z/OS 3.2 DFSMS Access Method Services Commands: Processor condition codes (IBM)
- z/OS 3.2 DFSMS Access Method Services Commands: SET command (IBM)
- GnuCOBOL 3.2 Programmer's Guide (cobc options) (GnuCOBOL project (GNU))
- GnuCOBOL 3.2 ibm-strict.conf: binary-size and binary-truncate (GnuCOBOL project (GNU))
Related tools
Report a problem with this lesson
Kept only in this browser. Your Learn progress