Send Output to the Spool With SYSOUT and MSGCLASS
Route job output to the JES2 spool with SYSOUT=* and a class, set MSGCLASS for the job log, control message volume with MSGLEVEL and read the SDSF datasets.

A batch job has no screen. Everything it says, from a program's report to the system's own account of what it did, goes to the spool, a set of datasets managed by the job entry subsystem, JES2, where it waits until someone looks at it, prints it, or purges it. Two JCL parameters decide where output lands: SYSOUT on a DD statement for the output of a program, and MSGCLASS on the JOB statement for the system's messages. This post explains both on z/OS 3.1 with JES2, how classes work, how MSGLEVEL controls the amount of JCL and allocation detail you get, and how the output looks in SDSF.
What the spool is
JES2 reads your job, runs it, and keeps what it produces in the spool, a pool of disk space it owns. Each piece of output is a separate dataset in the spool, belonging to the job, with an output class, a destination and a status. You see the pieces in SDSF, and each one can be opened, held, printed, routed elsewhere or purged. Nothing in the spool is permanent: installations purge output on a schedule, so anything worth keeping is copied to a dataset.
SYSOUT on a DD statement
A DD statement with SYSOUT= sends what a program writes to that name into the spool as a separate output dataset. The simplest form is:
//SYSPRINT DD SYSOUT=*The asterisk means "use the message class of the job," so the output joins the job log in the same class. You can also name a class directly, which is one letter or digit:
//REPORT DD SYSOUT=A
//ERRORS DD SYSOUT=X
//NOTES DD SYSOUT=(A,,STD1)The class decides what happens to the output. Classes are defined by each installation. A common arrangement has one class for held output that you read online and never print, such as X or H, and others for printers. The third form shows the second position, a writer name, empty here, and the third, a form name, STD1, which asks for particular paper or printer setup. The details differ at each site, so use your installation's list.
Other DD parameters refine where the output goes: DEST= sends it to a named destination such as a remote printer or another node, and HOLD=YES keeps it in the spool until someone releases it. COPIES= asks for more than one copy when it is printed.
MSGCLASS on the JOB statement
MSGCLASS= sets the output class for the job's own messages: the job log, a listing of the JCL as the system read it, and the allocation and termination messages. These are system-generated, and SYSOUT=* borrows the same class so a program's output sits beside them.
//MSGJOB JOB (ACCT),'SPOOL DEMO',CLASS=A,MSGCLASS=X
//STEP1 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSUT1 DD *
ONE LINE OF OUTPUT
/*
//SYSUT2 DD SYSOUT=*In SDSF, after the job ends, its output dataset list shows:
JESMSGLG JES2 2 (job log)
JESJCL JES2 3 (the JCL as read)
JESYSMSG JES2 4 (system messages)
SYSPRINT STEP1 102 (IEBGENER messages)
SYSUT2 STEP1 103 (the copied line)The columns shown by SDSF include the dataset name, the step that produced it, the ddname, the class and the number of lines. The numbers in the display above are examples, and every real job will have its own. The three JES2 datasets are always created for the job, so even a job with no SYSOUT of its own has output to read.
MSGLEVEL: how much to print
MSGLEVEL=(statements,messages) controls how much of the JCL and the allocation messages appear in the job output. The first value takes 0, 1 or 2 and says which JCL statements are printed:
| Value | JCL statements printed |
|---|---|
| 0 | Only the JOB statement |
| 1 | All input JCL, procedure statements and symbolic substitutions |
| 2 | Only the input JCL, without the procedure statements it expands to |
The second value is 0 or 1: 0 prints allocation and termination messages only if the job ends abnormally, and 1 prints all of them. MSGLEVEL=(1,1) is the usual setting for development, since it shows everything. Many installations set a default, so if you leave it out you get theirs.
Reading the job log in the right order
For a job that went wrong, the order to read is predictable. JESMSGLG first: it shows the job's sequence, the step return codes and the final status. Then JESJCL, which shows the JCL the system actually used, after substitution, with syntax errors marked. Then JESYSMSG, which holds the allocation detail, including the IEF285I lines for datasets and any IEF messages about devices. The program's own SYSOUT datasets come last, because they depend on the program having run.
Keeping output you want
Spool output goes away. To keep a program's report, write it to a dataset instead of SYSOUT, or copy it from the spool to a dataset. From SDSF, the XDC line command on an output dataset opens a dialog to write it to a dataset, which is the quickest way to save one. From JCL, a following step can use the OUTPUT and JESDS features, or a utility, but for a recurring need, change the program's DD to point to a dataset and use SYSOUT only for what you want to read once.
Common problems
No output appears. Check that the DD is spelled the way the program opens it, and that the class is one you can see. Output in a class that is only for printers sits unseen in the spool, and SDSF's DA or O display, with the right filters, shows it.
Too much output. A program that writes a line per record to SYSOUT can fill the spool, and the installation may kill the job at its output limit. Reduce the volume, or write a large listing to a dataset.
The job log is missing. If the job class or MSGCLASS sends messages to a class that is purged immediately, as some installations arrange for batch with no listings wanted, the job log never reaches the spool. Use a class that holds.
When this does not fit
Programs that write directly to a printer, to a file on the z/OS UNIX file system or to a network destination do not use SYSOUT. Systems that run JES3 have a similar concept with different commands. And modern shops often route job output to a log management tool, which reads the spool through a JES interface and keeps it longer than the spool does.


