Mainframe Path Start learning free
Core8 min readLesson 5 of 5

Compile, link, run — and debugging S0C7

Source becomes an executable in two stages: the compiler produces an object module, and the binder turns that into a load module in a library. Then JCL runs it. Knowing which stage failed halves your debugging time.

From source to running program
SourcePDS member, plus copybooks
CompileSyntax check → object module
Bind / linkResolve calls → load module
RunJCL, STEPLIB, data

Reading the compile listing

Return codeMeaningDo
0CleanNothing
4WarningsRead them — some are real bugs
8ErrorsFix; the object module may still be produced but is not trustworthy
12 / 16SevereNo usable output

The listing contains the expanded source with copybooks included, a cross-reference of every data name and where it is used, and the diagnostic messages. The cross-reference is genuinely useful: it answers 'where is this field set?' faster than searching.

Binder errors you will meet

SymptomCause
Unresolved external referenceA CALLed program was not found. Check SYSLIB and the call name spelling.
Module too largeRare; usually a runaway table definition.
Return code 4 with unresolved weak referencesOften normal for dynamic calls — check your site's expectation.

Debugging an S0C7 in five steps

  1. Find the offset. The abend message gives a PSW address and an offset into the failing program. Note it.
  2. Find the statement. Look up that offset in the compile listing's offset map to get the COBOL line number. If your site compiles with LIST or OFFSET, this is quick.
  3. Identify the field. The statement will do arithmetic on one or more numeric fields. One of them contains something that is not a number.
  4. Find the bad data. Look at the input record. Use the editor with HEX ON to see the actual bytes: a packed field should end in a sign nibble of C, D or F, and a display numeric should be all F0–F9.
  5. Fix the cause, not the symptom. Usually the field was never initialised, or the input record is a different layout from the one the program expects — a header or trailer record, a short record, or a file from the wrong source.
What bad numeric data looks like in hex
* a valid packed decimal field, PIC S9(5) COMP-3, value +12345
  12 34 5C

* the same field never initialised — low values
  00 00 00       <- no sign nibble, arithmetic abends

* a display numeric field, PIC 9(5), value 12345
  F1 F2 F3 F4 F5

* the same field containing spaces
  40 40 40 40 40   <- x'40' is a space in EBCDIC, not a digit

A compile-link-go job

A typical compile and bind job
//COMPLINK JOB (ACCT01),'COMPILE PAYSUM',CLASS=A,MSGCLASS=X,
//            NOTIFY=&SYSUID
//COMP     EXEC PGM=IGYCRCTL,
//            PARM='OBJECT,LIST,MAP,XREF,SSRANGE,TEST'
//STEPLIB  DD DSN=SYS1.COBOL.SIGYCOMP,DISP=SHR
//SYSIN    DD DSN=DEV.PAY.SOURCE(PAYSUM),DISP=SHR
//SYSLIB   DD DSN=DEV.PAY.COPYLIB,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSLIN   DD DSN=&&OBJ,DISP=(NEW,PASS),SPACE=(CYL,(1,1)),
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//*
//BIND     EXEC PGM=IEWL,PARM='LIST,MAP,XREF,RENT',
//            COND=(4,LT,COMP)
//SYSLIN   DD DSN=&&OBJ,DISP=(OLD,DELETE)
//SYSLMOD  DD DSN=DEV.PAY.LOADLIB(PAYSUM),DISP=SHR
//SYSLIB   DD DSN=SYS1.SCEELKED,DISP=SHR
//SYSPRINT DD SYSOUT=*

Common mistakes

Fixing the data instead of the program

Correcting one bad record gets tonight's run through. If the program cannot survive bad input, it will fail again next week.

Compiling without SSRANGE in test

Bounds checking in test catches subscript errors before production does, at a cost that does not matter in test.

Binding into the wrong load library

The classic 'my change did nothing' — the job's STEPLIB points somewhere else. Check the STEPLIB concatenation order.

Assuming RC=4 on a compile is safe

Some warnings — a moved field that will truncate, an unreachable paragraph — are real defects.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
← Logic, files and calling other programsBack to COBOL basics