Language Environment and production compiler options
Every Enterprise COBOL program runs on Language Environment, a shared run-time layer that handles storage, conditions and dumps. Compiler options then decide how strictly the generated code checks data and how fast it runs, so the same source can behave differently depending on how it was compiled.
What Language Environment is
Language Environment (LE) is the common run-time environment for COBOL, PL/I, C/C++ and assembler written to its conventions. Before LE, each language brought its own run-time library and its own way of handling errors. LE gives them one set of services, which is why a COBOL program can call a C routine and both report errors the same way.
LE services you will meet most often: allocating storage, intercepting program checks such as S0C7 and turning them into readable messages, writing a formatted dump, and reading run-time options.
Run-time options
Run-time options change how LE behaves without recompiling. Sites set defaults installation-wide; a job can override some of them, commonly through a CEEOPTS DD statement. Which options you may override is a site decision.
RPTOPTS(ON)TERMTHDACT(...)TRAP(ON)STORAGE(...)Compiler options that change behaviour
Compiler options are recorded at the top of every listing. When two environments behave differently with the same source, compare the options first.
| Option | What it controls | Production consideration |
|---|---|---|
| SSRANGE / NOSSRANGE | Run-time checks on subscripts, indexes and reference modification | Catches table overruns early. Many sites use it in test and weigh the small cost in production. |
| TRUNC(STD | OPT | BIN) | How binary (COMP) fields are truncated | STD truncates to the PIC digits. OPT is fastest but assumes data always fits. BIN uses the full binary capacity and is slower. |
| NUMPROC(NOPFD | PFD) | How signs on packed and zoned data are handled | PFD assumes every sign is the preferred one and is faster. With data from outside sources, invalid signs can make comparisons give wrong answers. |
| OPTIMIZE(0 | 1 | 2) | How hard the compiler optimises | Higher levels run faster and compile slower; optimised code can be harder to step through in a debugger. |
| ARCH(n) | Which hardware instructions the code may use | Must not exceed the oldest machine the program may run on, including disaster-recovery hardware. |
| TEST / NOTEST | Debugging information for the debugger | Suboptions affect what is kept; check your site standard. |
A TRUNC or NUMPROC change is not cosmetic. The same field can produce a different result under a different setting, so these options are usually fixed by site standard and changed only with testing.
Listing options worth having
- MAP shows where each data item sits in storage, so a dump offset can be turned into a field name.
- LIST or OFFSET maps generated code offsets back to statements, which is how you find the failing line from an abend.
- XREF lists where each data name and paragraph is used, invaluable for impact analysis.
- Keeping the production listing (many sites archive it automatically) is what makes 3 a.m. debugging possible.
Which compiler option adds run-time checking of subscripts and reference modification?
Show a hint
It is already in the glossary and starts with SS.
Show the solution
SSRANGE. It traps out-of-range subscripts with a clear message instead of letting the program overwrite storage.
Common mistakes
TRUNC, NUMPROC and ARCH can change results or make code fail on another machine. Check the options page in the listing whenever behaviour differs between environments.
TRAP(OFF) stops LE handling conditions, so you lose messages and dumps. Fix the underlying error instead.
Code built for a newer machine level can fail with an operation exception on older hardware. Set ARCH from the oldest machine the program could run on.
What you will see at work
- Compile procs and build tools set the standard options; developers rarely choose them program by program.
- Compiler upgrades are treated as projects, with regression testing because option defaults and behaviour can change between releases.
- Production support asks for RPTOPTS output or the CEEDUMP when an abend happens, to see exactly how LE was configured.
Key terms
Check your understanding.
Take this lesson's quiz and save your progress. Free.