Introduction

This chapter describes a list of SORT utility commands, and their functions.

1. Overview

SORT is a utility program, equivalent to IBM Mainframe’s DFSORT, which sorts, merges, copies, filters, reformats, and sums input data sets (SORTIN, SORTINnn) according to a given command, then saves the result to output data sets (SORTOUT and OUTFIL data sets). This utility uses a third-party solution, TmaxSoft ProSort.

2. Functions of SORT

The SORT utility provides the following key functions.

Task Description

SORT

Sorts the input data set records by the given key in ascending or descending order, and prints them to the output data set.

MERGE

Merges two or more input data sets, given in SORTINnn, by the given key. The input data sets must already be sorted by the given key.

COPY

Copies all records in the input data set to the output data set.

If the input data set is TSAM, choose one that matches first from the following record processing methods when using the main features of the SORT utility.

  • [F|V], for RECORD TYPE=[F|V].

  • RECFM, if the RECFM is fixed for the data set specified with SORTOUT DD.

  • RECFM, if the RECFM is fixed for the data set specified with OUTFIL DD.

  • V type, if SORTIN and SORTOUT are TSAM.

The SORT utility provides the following additional functions.

  • Conditional Input Filtering

    Before reformatting input records, this feature filters input records by the INCLUDE, OMIT, SKIPREC, and STOPAFT conditional options.

  • Input Record Reformatting

    This feature reformats input records that have passed through the input record filter. Reformatting is done with the INREC parameter before SORT, MERGE or COPY. Thus, reformatting can improve the SORT, MERGE, or COPY process by removing unnecessary fields.

  • Field Summation

    If records with the same key are found during the SORT or MERGE process, the SUM option adds up all values in the specified field. If EQUALS is set on the SUM option, once summation is completed, only the first record is output to the output data set set in SORTOUT and the other records are discarded.

  • Output Record Reformatting

    Once SORT, MERGE, or COPY is completed, the record can be reformatted according to the OUTREC parameter. This reformatted record is outputted to SORTOUT or becomes an input record for the OUTFIL parameter.

  • Output Duplication

    The OUTFIL parameter is used to use the output record set in SORTOUT as an input record that outputs to multiple "outfil DD". Input record filtering and output record reformatting can be applied again during this process.

3. Control Statements of SORT

This section introduces control statements of SORT.

3.1. Control Statements

A control statement largely consists of JOB statement, EXEC statement, DD statement, and /* statement.

  • JOB statement

    Located at the head of a JOB. Specifies the start of a JOB while defining the JOB.

    A JOB statement can be described as follows:

    //SORT00  JOB  CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1)
  • EXEC statement

    A single JOB is composed of various STEPs, and an EXEC statement, specifying a program name and parameters to be passed to the program, is located in the first part of a JOB STEP.

    An EXEC statement can be described as follows:

    //SORT  EXEC PGM=SORT,REGION=2M

    The following parameters can be used in SORT.

    Parameter Description

    'JPn"string"'

    Converts the area specified as JPn in a SORT script to strings.

    VLTESTI=n

    Defines the behaviors in cases where the fields specified in the INCLUDE or OMIT operations are not found or only partially exist in the input records.

    • VLTESTI=0: The entire range of all fields specified in the INCLUDE or OMIT operations must exist in the input records. Otherwise, an error occurs. If the VLTESTI parameter is not specified, it has the same behavior as with VLTESTI=0.

    • VLTESTI=1: For INCLUDE operations, if the specified fields are not found or only partially exist in the input records, the records are not output. For OMIT, if the specified fields are not found or only partially exist in the input records, the records are output.

    • VLTESTI=2: If the fields specified in the INCLUDE or OMIT operations are not found or only partially exist in the input records, the relational expression is considered to be 'false.'

  • DD statement

    Specifies names and attributes of data sets to be used to execute SORT. They can be specified with the following data sets:

    Data Set Description

    SYSIN

    Enters SORT control statements. Uses generally the input stream of the system with DD *.

    SYSOUT

    Lists control statements and prints messages. Uses generally the output stream of the system.

    SORTIN

    Input data set for SORT and COPY processing.

    SORTINnn

    Input data set for MERGE processing. A data set name is not necessarily defined in order from SORTIN01, but the same number cannot be used for different data sets.

    SORTWKnn

    Used as a work area for SORT processing.

    SORTOUT

    Outputs the result of SORT, MERGE or COPY processing. If SORTIN or SORTINnn have a fixed length (FB), the length of SORTOUT must be fixed as well, and if SORTIN or SORTINnn has a variable length (VB), the length of SORTOUT must also be variable. It can output NVSM records to VSAM records, and vice versa.

    SORTOFxx

    Outputs records reformatted with OUTFIL to multiple output data sets. xx is an Alphabetical or numerical string that consists of one or two characters.

    SYMNAMES

    Data set to reference when converting symbols.

    • Record Format

      Symbol name, starting position of field, length of field, format of field

    JNFnCNTL

    Control statement of subtaskn in JOIN operations. Set the SORT statement to execute before the execution of a JOIN statement. n is set to 1 or 2.

  • /* statement

    Specifies the end of a SYSIN data set. The end of the data set can also be set by using END in the SORT control statement.

3.2. Data Set Definition

The following operands are used for data set definition:

Data Set DCB DISP DSN LABEL SPACE UNIT VOL AMP

SORTIN

1

2

3

3

7

SORTINnn

1

2

5

3

3

7

SORTOUT

1

4

2

5

3

6

7

SORTOFxx

1

4

2

5

3

6

7

SORTWKnn

4

4

5

3

6

SYMNAMES

1

2

3

3

JNFnCNTL

1

4

4

2

5

3

3

7

  • O: Must be specified.

  • X: Not needed to be specified.

  • 1: Needed to be specified according to circumstances.

  • 2: Not necessary on disk.

  • 3: Must be specified unless the data set has been written and cataloged before the current JOB STEP.

  • 4: Must be specified unless the data set is temporary.

  • 5: Must be specified if the data set is directly written on the access device.

  • 6: Must be specified unless the data set is temporary, it has been written and cataloged before the current STEP, or it has been passed from another STEP in the JOB.

  • 7: Can be specified for VSAM data sets, for others, it is not necessary.

Sub-parameters of DCB Operand

If the I/O data set is non-VSAM, specify the following parameters.

Parameter Description

Record Format (RECFM)

Sets the format of a record stored in the data set.

Record Length (LRECL)

Sets the maximum logical length of a record stored in the data set. (Unit: bytes)

Block Size (BLKSIZE)

Sets the maximum physical length of a record stored in the data set. (Unit: bytes)

The parameters can be handled in the following order.

  1. If RECFM, LRECL and BLKSIZE are specified as DCB operands in a DD statement, they are used and other information is ignored.

  2. An input data set for which DCB operands are not specified may cause an error. If a data set already exists, the existing information is used. An output data set for which DCB operands are not specified can be set as follows:

    1. Uses information specified in OUTREC.

    2. Uses information specified with RECORD.

    3. Uses information specified in INREC.

    4. Uses information specified in the input data set.

4. General Coding Rules

This section describes the syntax used to create a SORT command.

figure sort fields
Syntax of SORT command
Classification Description

LabelField

A label field can be omitted, or used as needed. It begins from the first column of the line. A blank or '*' character cannot be used in the first column. A label can be specified from column 1 to 70, and a blank indicates an end of the label.

Operation Field

Specifies commands to be performed by a program like SORT and MERGE. The field can be specified between columns 2 and 71 in the first line.

Operand Field

Operand fields can be concatenated with a comma, and an operand field comes after an operation field and at least one blank. A blank cannot be used in an operand field.

Remark Field

Any contents like a comment can be specified, and they are ignored while the program is running. A remark field comes after an operand field and its following one or more blank characters.

Continuation Column (72)

The 72nd column is a continuation column. If a character other than a blank is specified in this column, it means that the current statement is continued in the next line. If an operand field ends with a comma, the next line is read as continuation of the operand.

Columns 73 - 80

Can freely be used. They are not read in the program.

Continuation Lines

A continuation line is a logical extension of the previous line. It can be continuation of an operand or a comment.

  • Continuation of an operand: If an operand ends with a comma between column 2 and 71, the next line is considered as continuation of the operand. Furthermore, when an operand is continued to column 71, and a character other than a blank is in column 72, it means that the operand is continued on the next line.

  • Continuation of a comment: If an operand ends without a comma as its last character between column 2 and 71, and a character other than a blank is specified in column 72, the next line is considered as continuation of a comment, and will be ignored in the program.

The first column starting with '*' is a comment. A blank line in a command is ignored. Therefore, the blank line does not affect continuation.