Structure of a Job

When we ask MVS to run programs for us, we do this by submitting a job.


Sequence of events

  1. We write the JCL file.

  2. We submit the JCL file to MVS using MVSBatch.

  3. The Job Entry System (JES), a subsystem of MVS, reads the JCL file and checks it for various kinds of errors. If there are errors, we are informed of this rapidly.

  4. If no errors have been found, JES converts the information in the JCL to an internal format (control blocks, etc.), and the job waits its turn in the job queue.

  5. Eventually the job is executed.

  6. The results may be sent to a printer or they may come back to us in a Jnnnn.X file. (We can control this by choosing different MVSBatch menu items.)


What does a JCL file look like?

There are three principal kinds of statements in JCL: JOB, EXEC and DD. There are also a number of less common kinds of statements such as PROC, PEND, and JCLLIB, and there are also JES statements such as JOBPARM.

The overall JCL file begins with a JOB statement.

A job is composed of steps. Each step starts with a EXEC statement and executes either a program or a JCL procedure. A JCL procedure is a kind of macro for JCL. A procedure is also made of steps, and when the procedure is expanded (like a macro), its own steps become actual steps in the original job. Thus, ultimately we have steps which each execute a program.

Data sets are represented in JCL by DD statements. As programs work with data sets, each step has zero or more DD statements as well as its EXEC statement.

Thus the skeleton of a job looks like this:

          JOB statement
          1st step:  EXEC 
                     DD statements 
          2nd step:  EXEC 
                     DD statements
          (Maybe more steps)

A job must have at least one step and may have as many as 255 steps. Each program will provide a return code, and the return codes from the various steps are listed on the first page of the listing. (This includes programs executed in steps we inherited from a procedure.)


What else can be in a job?

At the top of the job, before we have any steps, we can have some or all of thesee:


Format of a JCL line

JCL instructions are written on lines 80 spaces long. We do not use columns 73-80 at all, and we very seldom use column 72.

The character set used to write JCL consists of letters A-Z, digits 0-9, and the "national" characters $, @ and #. In general, names we invent to use in JCL are 1-8 characters long and do not begin with digits.

JCL lines begin with // in columns 1 and 2. JES lines such as JOBPARM begin with /* in columns 1 and 2.

In writing JCL instructions, we often need to continue from one line to the next. That is, we may be writing an EXEC statement or a DD statement, and there may be to many parameters to list on one line. To continue to the next line, we end the first line with a comma and then continue listing parameters on the next line, starting somewhere between columns 4 and 16.

Do not insert blank spaces in the middle of a line of JCL! This will be interpreted as the end of that line, and anything after the space will be regarded as line documentation.

The very last line in the JCL starts with // and has nothing else on that line. Nothing after it will even be read. (This can be a good place to write yourself a note.)


Comments in JCL

As noted above, it is possible to have line documentation in JCL. To make a whole line into a comment (often easier to read), start the line with //* in columns 1 through 3.