JCL for sorting data sets directly

The job control language (JCL) you need to do a sort depends on whether you run DFSORT directly or call DFSORT from a program. For now, concentrate on running DFSORT directly. Information on calling DFSORT from a program is presented in Calling DFSORT from a program.

Your operating system uses the JCL you supply with your DFSORT program control statements to:

You must supply JCL with every DFSORT job you submit.

Required JCL includes a JOB statement, an EXEC statement, and several DD statements. The statements you need and their exact form depend upon whether you:

Information on when you would choose each of the previous options is detailed in z/OS DFSORT Application Programming Guidez/OS DFSORT Application Programming Guide.

The JCL statements you need for most jobs are as follows.
//jobname JOB
Signals the beginning of a job. At your site, you might be required to specify information such as your name and account number on the JOB statement.
//stepname EXEC
Signals the beginning of a job step and tells the operating system what program to run. To run DFSORT, write the EXEC statement like this:
//stepname  EXEC  PGM=SORT
//STEPLIB DD
The DFSORT program would typically be in a library known to the system, so the //STEPLIB DD statement would not be needed. However, if DFSORT is not in a library known to the system, the //STEPLIB DD statement defines the library containing the DFSORT program
//SYSOUT DD
Defines the data set in which DFSORT messages and control statements are listed.
//SORTIN DD
Defines the input data set or concatenated input data sets.
//SORTWKdd DD
Defines a work data set for a sort. Typically not needed, because DFSORT can allocate work data sets for a sort dynamically.
//SORTOUT DD
Defines the output data set.
//SYSIN DD
Precedes or contains the DFSORT program control statements.

The following is a typical example of JCL to run DFSORT.

//EXAMP    JOB  A492,PROGRAMMER
//SORT     EXEC PGM=SORT
//SYSOUT   DD   SYSOUT=A
//SORTIN   DD   DSN=A123456.SORT.SAMPIN,DISP=SHR
//SORTOUT  DD   DSN=A123456.SORT.SAMPOUT,DISP=OLD
//SYSIN    DD   *
    SORT FORMAT=CH,
         FIELDS=(110,10,A,145,17,A,1,75,A)
/*

z/OS DFSORT Application Programming Guide contains additional information on running DFSORT directly.

So far
So far in this chapter you covered how to write a SORT program control statement and how to run that sort with JCL statements. The next tutorial explains how to use the MERGE program control statement to merge two data sets.