This document briefly describes how to use SyncSort in z/OS (OS/390) to sort an OS data set. It describes the SYNCSORT cataloged procedure, lists required ddnames used by SyncSort, gives an example of sorting a file, and includes how to obtain SyncSort manuals.
Related search terms include utilities, JCL, PL/I, Assembler, and COBOL.
Table of Contents
SyncSort is the only general-purpose sort program supported under z/OS (OS/390) at EI&O. You can use SyncSort any of the following ways:
through the SYNCSORT cataloged procedure,
by invoking it in your own JCL (
// EXEC PGM=SORT,...),
from a program written in Assembler, COBOL, or PL/I.
This document primarily describes how to use the
SYNCSORT cataloged procedure. You should have a general familiarity with JCL and/or one of the languages mentioned above.
SyncSort has the following functions:
sort -- to rearrange data set records in chronological or alphabetical order, producing a specific sequential form
merge -- to combine as many as 32 sequential data sets into 1 data set under the same sequence
copy -- to reproduce a file, bypassing the sorting process entirely
SyncSort uses the following ddnames:
defines the input data set for a sorting application; not required for a merge-only operation.
define the input data sets for a merging application; not required for a sorting application.
define intermediate storage data sets for a sorting application; not required for a merge.
defines the output data set for a sorting or merging
application; should not be the same as the
SORTIN data set because a system failure could then destroy both your output and your data.
is used as the system message data set.
defines the application control data set.
SyncSort uses the default system region size unless you specify a region size. The current system default at EI&O is 1M (1024K). SyncSort allows you to specify up to 4M by using the
REGION= parameter on the
SYNCSORT procedure is the only supported sort procedure. Figure 1 shows the JCL for
You need to supply the SORTIN, SORTOUT, and SYSIN DD statements.
Figure 1. JCL for the
//jobname JOB (,,
node.location//SORT EXEC SYNCSORT //SORTIN DD
...input data set...//SORTOUT DD
...output data set...//SYSIN DD *
... sort control statements ...
The following optional keyword parameters can be added to the
The default is no
options. Add this parameter to the
EXEC statement as in shown below to specify any desired SyncSort options. For valid options, see the "Options" section below.
//SORT EXEC SYNCSORT,OPTION='
this keyword to specify the region size for the
SORT utility. For example,
//SORT EXEC SYNCSORT,REGION=2M
By default, the sortwork data sets will be allocated on the work packs. Use this parameter to specify a particular volume.
Figure 2 shows the basic JCL needed to sort a data set if you do not use the
SYNCSORT cataloged procedure.
If you have a very large data set, you may need to request more than 5 cylinders of work space. Also, do NOT specify more
SORTWK DD statements than there are temporary packs available. There are
currently four. This causes negative system and job performance and may result in your job being cancelled.
Figure 2. JCL for Using SyncSort.
//SORTIT JOB (,,
node.location//SORT EXEC PGM=SORT,PARM='
options' //SORTLIB DD DSN=SYS1.SORTLIB,DISP=SHR //SYSOUT DD SYSOUT=A //SYSPRINT DD SYSOUT=A //SORTWK01 DD UNIT=SYSDA,SPACE=(CYL,(5,3)) //SORTWK02 DD UNIT=SYSDA,SPACE=(CYL,(5,3)) //SORTWK03 DD UNIT=SYSDA,SPACE=(CYL,(5,3)) //SORTIN DD DSN=
your.input.data.set,DISP=OLD //SORTOUT DD ... DD
statement for output data set ...//SYSIN DD *
... SyncSort control statements
Refer to the documentation for Assembler, COBOL, or PL/I for information on how to invoke SyncSort from within a program.
SYNCSORT cataloged procedure, you can add an OPTION parameter to the
EXEC statement as follows:
// EXEC SYNCSORT,OPTION='
If you are using your own JCL rather than using the
SYNCSORT cataloged procedure, you can specify options in the PARM parameter of the
EXEC statement, as in this example:
// EXEC PGM=SORT,REGION=
For program-initiated sorts, use the $ORTPARM
DD statement, as in this example:
(col 72) //$ORTPARM DD * CORE=MAX-32K X RESET
The following are SyncSort default parameters, which you can change as described above.
BMSG lists alternate parameters specified through
$ORTPARM on the output message data set.
This default causes limited validation of the data contained in fields designated as packed
or zoned decimal. To have the sort terminate if data in
ZD fields are invalid, specify
program-invoked sorts with exit routines, you must determine the amount of memory needed by the exits, then specify
will suppress the SyncSort SNAP dump, which is produced in the event of a critical error. If you have a
DD statement, you will receive the normal OS dump. If you require a SNAP dump, specify
e DEBUG parameter.
For a more efficient sort, the order of the records is not preserved. If the order needs to be
retained, use the
Error messages are issued when an I/O error occurs. If
is specified, a USER 999 ABEND will occur.
Control statements will be listed on the SYSOUT data set.
NOLIST will turn this off.
The default DD name of the message data set is SYSOUT. Any other valid DD name can be substituted.
be compatible with the display options of COBOL exit routines, the defined characteristics of the message data set are:
unsuccessful sort will issue a return code of 16. If
RC16=ABE is specified, a USER 16 ABEND will occur.
Unused space in sortwork data sets will be released during execution time unless the sort is program-initiated.
To release excess space on the SORTOUT
RLSOUT can be specified.
RESET must be given as a parameter if the SORTOUT data set is
a VSAM file that was created with the
REUSE option to prevent SyncSort from treating SORTOUT as a MOD data set.
A secondary allocation is given to the sortwork data sets if needed.
No validity testing of variable-length records will be done.
SyncSort uses the following program control statements:
For a sort application, the
SORT statement specifies the sort order. The general form of the
SORT statement is as follows:
in which "
n" is an estimate of the number of records to be sorted. Sort keys specify the fields within the record upon which to sort, their data types, and whether they are to be sorted in ascending or descending
Each sort key has the following four parts: starting byte, length in bytes, format, and order.
specifies the starting byte position in the record relative to byte 1, which is the first byte. For variable-length records, the offset must include the record descriptor, so the first byte of the data portion of the record is position 5.
specifies the length of the field in bytes.
must be a valid data type, such as one of the following:
alternate sequence as specified by the ALTSEQ control statement
is either A for ascending order, D for descending order, or E as modified by an E61 exit.
The following example helps to illustrate how to
SORT a data set. Suppose you have a card-image (80-byte records) data set called UF.userid.GRADES, which is to be sorted alphabetically by student name within the same letter grade.
Assume the name is in columns 1-25 and the letter grade is in column 50 of each record, and there are approximately 100 students in the file. Figure 3 shows a sample job setup using the
SYNCSORT cataloged procedure.
The input data set is UF.userid.GRADES. The output data set will be sent to the printer.
Figure 3. Example to
SORT a Data Set.
//SORTLST JOB (,,
node.location//SORT EXEC SYNCSORT //SORTIN DD DSN=UF.
userid.GRADES,DISP=SHR //SORTOUT DD SYSOUT=A //SYSIN DD * SORT FIELDS=(50,1,CH,A,1,25,CH,A),FILSZ=E100
Documentation for the SyncSort utility is in the SyncSort Release 3.4 Programmer's Guide from SyncSort, Inc. You can order manuals from the vendor at this address:
50 Tice Boulevard
Woodcliff Lake, NJ 07675
Fax: (201) 930-8284
Attn: Syncsort Product Services
We welcome your comments and suggestions on this and all UFIT documentation. Please send your comments to: