DISPLAY statement
The COBOL statement that writes a line of text, usually to the job's output, often used for messages and debugging.
Also written DISPLAY, COBOL DISPLAY, DISPLAY UPON CONSOLE
DISPLAY writes a line of text. DISPLAY 'RECORDS READ: ' WS-COUNT writes the words followed by the value of the counter. In a batch job, the output goes to the job's SYSOUT, where you can read it in SDSF.
It is the simplest way for a program to report what it did, such as counts of records read, written and rejected at the end of a run. It is also the quickest way to debug: add a few DISPLAY statements to see which paragraphs run and what values fields hold.
Numeric fields are shown as readable digits, even if they are packed or binary. That makes DISPLAY a safe way to see their values.
Two warnings. DISPLAY UPON CONSOLE writes to the operator's console, which is usually not allowed without a good reason. And debug DISPLAYs left in production code can fill the output with thousands of lines. Remove them, or put them behind a switch, before the program is promoted. In CICS programs, use CICS facilities for messages instead of DISPLAY.
Where can I learn this hands-on?
Right here, at ZedBank. You take a junior job at a simulated bank and learn each part of the work by doing it, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- SYSOUTOutput sent to the spool rather than to a dataset, where you can read it after the job finishes.
- Job logThe part of a job's output written by the system rather than the program: what happened to the job, step by step.
- COBOLThe programming language most business logic on the mainframe is written in. Verbose by design, and still running the world's payments.
- PROCEDURE DIVISIONThe part of a COBOL program that contains the actual logic, the statements that run.
- SpoolThe system-managed holding area where job output waits to be read, printed or purged.