Mainframe Path Start learning free
Applied10 min readLesson 2 of 3

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.

Where LE sits
Your COBOL programbusiness logic
COBOL run-time routinesfile handling, arithmetic, IGZ messages
Language Environmentstorage, condition handling, CEE messages, CEEDUMP
z/OSaddress space, I/O, abend codes

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.

Run-time options you will seeWhat it means
RPTOPTS(ON)
Prints the options actually in effect, so you can prove what the program ran with.
TERMTHDACT(...)
Controls what LE produces when a program ends abnormally, for example a message only, a traceback, or a CEEDUMP.
TRAP(ON)
Lets LE intercept program checks. Leave it on: turning it off removes LE's condition handling.
STORAGE(...)
Can initialise storage to a set value, useful in test for flushing out uninitialised fields.

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.

OptionWhat it controlsProduction consideration
SSRANGE / NOSSRANGERun-time checks on subscripts, indexes and reference modificationCatches 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 truncatedSTD 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 handledPFD 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 optimisesHigher 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 useMust not exceed the oldest machine the program may run on, including disaster-recovery hardware.
TEST / NOTESTDebugging information for the debuggerSuboptions 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

TRY IT YOURSELF

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

Assuming options do not matter

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.

Turning TRAP off to hide an error

TRAP(OFF) stops LE handling conditions, so you lose messages and dumps. Fix the underlying error instead.

Raising ARCH without checking DR hardware

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

Key terms

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

Take the lesson quiz
← Subprograms, CALL linkage and nested programsDebugging, performance, JSON/XML and maintainable code →