Where PL/I is used and how a program is built
PL/I was designed by IBM in the 1960s to serve both business and scientific programmers. A program is a set of procedures and blocks made of semicolon-terminated statements, with every variable described in a DECLARE.
Why PL/I exists
In the early 1960s, business shops used COBOL and scientific shops used FORTRAN. IBM designed PL/I alongside System/360 to do both: decimal arithmetic for money, floating point for engineering, plus pointers, strings and structured error handling. It never displaced COBOL, but many large organisations adopted it and never left.
Where you will find it
- Banks and insurers, particularly in parts of Europe, where core account and policy systems were written in PL/I.
- Utilities, airlines and government agencies with long-lived batch systems.
- System tools and vendor products, because PL/I handles pointers and strings comfortably.
- Mixed shops where PL/I and COBOL programs call each other, sharing Language Environment at run time.
The current IBM compiler is Enterprise PL/I for z/OS. PL/I runs in batch, under CICS and IMS, and with embedded SQL for DB2, much as COBOL does.
The shape of a program
PL/I is free-form: statements end with a semicolon, not a period, and layout is up to you. Comments sit between /* and */. Keywords can be abbreviated, so DECLARE is often written DCL and PROCEDURE as PROC.
HELLO: PROCEDURE OPTIONS(MAIN);
DCL NAME CHAR(20) INIT('WORLD');
DCL COUNT FIXED BIN(31) INIT(0);
COUNT = COUNT + 1;
PUT SKIP LIST('HELLO', NAME, COUNT);
CALL SHOW_TOTAL(COUNT);
SHOW_TOTAL: PROC(N);
DCL N FIXED BIN(31);
PUT SKIP LIST('TOTAL IS', N);
END SHOW_TOTAL;
END HELLO;HELLO: PROCEDURE OPTIONS(MAIN);DCL NAME CHAR(20) INIT('WORLD');PUT SKIP LIST(...)SHOW_TOTAL: PROC(N);END HELLO;Blocks and scope
PL/I has two kinds of block. A PROCEDURE is entered only when called. A BEGIN block is entered when execution reaches it, and is used to create local variables or to group statements in an ON-unit. Variables declared in a block are visible in that block and in blocks nested inside it, unless redeclared.
Declare everything
PL/I will invent a declaration for an undeclared name, using defaults based on its first letter. A typing mistake therefore becomes a new variable instead of a compile error. The compiler warns about implicit declarations; treat those warnings as errors, and follow your site standard if it enforces explicit declarations through compiler options.
What PL/I keyword marks the procedure where a program starts? Type the option name inside the parentheses.
Show a hint
PROCEDURE OPTIONS(....)
Show the solution
MAIN. The main procedure is written NAME: PROCEDURE OPTIONS(MAIN);
Common mistakes
PL/I statements end with a semicolon. A COBOL habit of periods produces confusing compile errors.
A misspelt name silently becomes a new variable with default attributes. Declare every variable and act on the compiler's warnings.
An END without a label closes the nearest open block, which may not be the one you meant. Put the label on END for procedures and long blocks.
What you will see at work
- In PL/I shops you will often maintain programs that call COBOL routines or are called by them, so both languages appear in the same incident.
- Code reviews check for explicit declarations and labelled END statements because they prevent whole classes of bugs.
- PL/I skills are scarcer than COBOL skills, so being able to read it is a real advantage in maintenance teams.
Key terms
Check your understanding.
Take this lesson's quiz and save your progress. Free.