Professional Documents
Culture Documents
Table of Contents
1. OverView ...................................................................................................... 1
2. SYNCSORT Commands ............................................................................... 2
2.1 SORT......................................................................................................... 2
2.2 MERGE ..................................................................................................... 2
2.3 INCLUDE and OMIT................................................................................ 2
2.4 INREC and OUTREC ............................................................................... 3
2.5 SUM .......................................................................................................... 3
2.6 ALTERNATE COLLATING SEQUENCE .............................................. 4
2.7 OPTION Statement ................................................................................... 4
2.7.1 EQUALS AND NOEQUALS ............................................................. 4
2.7.2 RECORD............................................................................................. 4
2.7.3 SKIPREC............................................................................................. 4
2.7.4 STOPAFT............................................................................................ 4
2.7.5 COPY .................................................................................................. 5
2.8 OUTFIL..................................................................................................... 5
3. JCL Requirement........................................................................................... 5
SYSIN . ...................................................................................................... 5
SYSOUT ..................................................................................................... 5
SORTIN ...................................................................................................... 5
SORTIN## .................................................................................................. 5
SORTOUT .................................................................................................. 5
SORTOUT# ................................................................................................ 5
SORTOT## ................................................................................................. 5
SORTWK##................................................................................................ 5
4. PROCESSING ORDER ................................................................................ 5
1. OVERVIEW
Syncsort belongs to Syncsort IncC that can sort data, merge data, selectively process data,
reformat data, create summary records from data and create extensive reports from input data. It
can also perform any combination of the above mentioned functions and more. This document
tries to explain in brief the various items related to processing data using Syncsort. This document
describes a subset of the Syncsort functions and does not claim to be a replacement nor does the
author guarantee the exactness of details or syntax.
Syncsort.doc Page 1 of 6
SYNCSORT - AN OVERVIEW
2. SYNCSORT COMMANDS
2.1 SORT
The SORT statement can be used sort a dataset or concatenated datasets. The SORT statement
requires the sort sequence for the data. The list of fields and their formats must be specified for
this statement. The output records are sorted in the specified sequence. The multiple records
contain the same sort sequence key, then the options specified will determine if the input order is
maintained for such records. The format of the SORT statement is as follows.
SORT FIELDS=({begcol},{length},{fieldtype},{D|A}[,{begcol},
{length},{fieldtype},{D|A}]...)
or
SORT FIELDS=({begcol},{length},{D|A}[,{begcol},{length},
{D|A}]...),{fieldtype}
The beginning column is specified in bytes, starting with 1 for the first byte. The length of the
field must be specified in bytes, irrespective of the field type. There are many field types. The
frequently used ones are CH for character, BI for binary (COMP fields of COBOL), PD for
packed decimal (COMP-3 fields of COBOL), ZD for zone decimal and AQ for alternate collating
sequence (refer to later section on alternate collating sequence). The second form of the SORT
statement can be used when all the fields specified for the sort sequence are of the same type.
2.2 MERGE
The MERGE statement can be used merge two or more pre-sorted datasets. The MERGE
statement requires the sort sequence for the data. The list of fields and their formats must be
specified for this statement. The format of the MERGE statement is as follows.
MERGE FIELDS=({begcol},{length},{fieldtype},{D|A}[,{begcol},
{length},{fieldtype},{D|A}]...)
or
MERGE FIELDS=({begcol},{length},{D|A}[,{begcol},{length},
{D|A}]...),{fieldtype}
Please refer to SORT statement above for description of the statement.
Syncsort.doc Page 2 of 6
SYNCSORT - AN OVERVIEW
INCLUDE COND=({begcol},{length},{fldtype},{comp.oper},
{constant})
The above statement can be used to compare a field in the record with a character, decimal or
hexadecimal constant.
Using the convention that {cond.stmt} is the part of statement between the parenthesis in either of
the statements mentioned above, compound statements can be constructed as follows.
INCLUDE COND=({cond.stmt},[{OR|AND},{cond.stmt}]...)
Parenthesis can be used to group conditional statements to form complex conditions. For OMIT
statements replace the INCLUDE verb by OMIT verb in the above examples.
2.5 SUM
The SUM statement can be used to summarize data based on the SORT statement. One record
will be produced for each unique key present in the input. If numeric fields are specified for
summation, those fields will be summed up. The SYNCSORT software does not guarantee unique
records if numeric fields are required to be summed up. Whenever there is an overflow of a
numeric field, more than one record may be created. The syntax is as follows.
SUM FIELDS=NONE
or
Syncsort.doc Page 3 of 6
SYNCSORT - AN OVERVIEW
SUM FIELDS=({begcol},{length},{fldtype}[,{begcol},{length},
{fldtype}]...)
The first format is used when duplicate records need to be removed and no numeric summation is
required. The second format is used when numeric summation is required when duplicate records
exist.
2.7.2 RECORD
The record option of the OPTION statement can be used to specify if the input data to be
processed are Variable length records or Fixed length records. This is required when both the
input and output from the SORT or MERGE processing are VSAM files. The valid values are
RECORD=V and RECORD=F.
2.7.3 SKIPREC
The SKIPREC parameter of the OPTION statement can be used to specify the number of records
of input to skip before any processing should begin. SKIPREC=20 specifies that the first 20
records of the input must be skipped.
2.7.4 STOPAFT
The STOPAFT parameter of the OPTION statement can be used to specify the number of records
to be included for processing. STOPAFT=100 specifies that SYNCSORT stop taken any more
input after 100 records that match the criteria are selected.
Syncsort.doc Page 4 of 6
SYNCSORT - AN OVERVIEW
2.7.5 COPY
The COPY parameter can be used if a simple COPY operation is required. If neither SORT
processing nor MERGE processing is required this is ideal to use. The parameter when combined
with SKIPREC and STOPAFT helps copy selected records to output based on number of records.
If COPY is combined with INCLUDE or OMIT condition statements, selected records can be
copied to output based on specific conditions in field values. When COPY is combined with
INREC or OUTREC processing (INREC is more efficient in this case), a reformatted output can
be produced.
2.8 OUTFIL
The OUTFIL statement can be used to produce multiple output datasets. This statement must be
used if elaborate formatting is required, like producing reports. One OUTFIL statement is
required for each output dataset. The FILE parameter specifies the DD name suffix to be used for
the dataset output.
Each output dataset can have its own INCLUDE or OMIT condition and its own INREC and
OUTREC parameters. Further, report formatting is available, including 3 levels of HEADER#, 3
levels of TRAILER#, summation, Section processing and Section breaks. For example, this
statement can help create separate reports for each department into a different dataset or sysout
and route them to the appropriate destination.
The SYNCSORT manual should be referred if the OUTFIL statement is required.
3. JCL REQUIREMENTS
The different DD statements required for the SORT step are as follows.
4. PROCESSING ORDER
The processing order of the control statements by SYNCSORT is as follows.
Syncsort.doc Page 5 of 6
SYNCSORT - AN OVERVIEW
Syncsort.doc Page 6 of 6