SORT control statement

Top  Previous  Next
SORT    FIELDS=[(p,m,f,s) | (p,m,s),FORMAT=f | COPY | (COPY) ],
[ EQUALS | NOEQUALS ],
[ SKIPREC=k ],
[ STOPAFT=a ],
[ Y2PAST=y ],
[ FILES=n ]

 

The SORT control statement must be used when a sorting application is performed; this statement describes the control fields in the input records on which the program sorts. A SORT statement can also be used to specify a copy application.

FIELDS parameter

Describes the control fields for which records must be sorted. Requires four facts about each control field in the input records:

 

Facts

Description 

p

the position of the field within the record

l

the length of the field

f

the format of the data in the field (my be omitted if FORMAT is specified).

It may assume any supported format. See the FORMAT parameter for the list of supported formats.

s

sequence into which the field is to be sorted (A or D)

 

The ordering sequence s may be:

Sequence 

Description 

A

ascending 

D

descending 

FORMAT parameter

Defines the format for the control fields. This option may be used only if all the fields have the same format.

Supported formats:

Format

Length in bytes

Description

BI

1-4092

unsigned binary

CH

1-4092

character

CE

1-4096

EBCDIC character

AQ

1-4096

character with alternate collating sequence

PD

1-32

signed packed decimal

ZD

1-32

signed zoned decimal

FI

1-256

signed fixed-point

Y2C or Y2Z

2

two digit char or zoned year

Y2B

1

two digit binary year

Y2P

2

two digit packed year

BL

2,4,8

2, 4 or 8 byte long little endian binary

COPY parameter

When the COPY parameter is specified no SORT occurs on input records.

Option 

Description 

[NO]EQUALS

only for compatibility reason: XSORT 2 always preserve the original sequence

SKIPREC=k

skips the first k input records while processing

STOPAFT=a

stop reading input after a records

Y2PAST=y

sets the Y2K threshold to y

FILES=y

sets number of SORTIN files (VSE mode)y