Skip to content

Sort Tasklet

Summer.Batch.Extra.Sort.SortTasklet tasklet can sort or merge files using the syntax of DFSORT. It is useful when modernizing batches from z/OS mainframes. Only supported features are described in this section, see the DFSORT documentation for more details on the legacy syntax.

Specifying input and output files. The input files are specified using Input property, which expects a list of resources, and the output file are specified using Output property, which expects a resource. The encoding of input files can be set using the Encoding property. If no encoding is specified, the default encoding is used. All input files must have same encoding, which will be preserved in the output. If input files have the header, it must be specified using HeaderSize property; this header will be reproduced in output file.

Reading and writing records. A record is a unit of information that can be sorted. A sorted tasklet supports three types of records: (1) records separated by a character string (e.g., records separated by new line characters), (2) fixed-length records, and (3) records with a record descriptor word (RDW) specifying size. For separated records, the separator must be set with Separator property. For fixed-length records, the length must be set with RecordLength property. If none of these properties have been set, the tasklet will assume that records have an RDW.

Sorting files. To sort files, sort card must be specified with SortCard property. If it is set, a comparer will be generated to sort records in input files, otherwise records will be kept in original order as in the input files. The sort card should respect DFSORT syntax (see section Supported DFSORT Features for more information).

Filtering records. Records can be filtered using Include and Omit. Each property uses DFSORT syntax for records selection. Only records that are selected by Include and not selected by Omit will appear in the output.

Transforming records. Records can be transformed using Inrec and Outrec properties. Each property uses DFSORT syntax for record transformation. Records are transformed before and after they are sorted or filtered using Inrec and Outrec respectively.

Managing duplicates. By default, all identical records will appear in the output. The order among these identical elements in unspecified. If SkipDuplicates property is set to true, only one of identical records will be kept (the selection is also unspecified). It is also possible to sum the lines by setting Sum property with a DFSORT sum card.

Supported DFSORT Features

Sort Card

The sort card can either be a list of fields or specify a default format using the following syntax:

[FORMAT=<format>,]FIELDS=<fields>[,FORMAT=<format>]

The fields should conform to DFSORT syntax, but only the following formats are supported:

  • String (CH)

  • Zoned (ZD)

  • Packed (PD)

  • Signed binary (FI) and unsigned binary (BI)

Include and Omit Cards

As with sort cards, include and omit cards can either be a list of conditions or specify a default format:

[FORMAT=<format>,]COND=<conditions>[,FORMAT=<format>]

The conditions should conform to DFSORT syntax and supports the following features:

Comparable elements

  • Fields

  • Decimal constants

  • Character string constants

Field formats

  • String (CH) and sub-string (SS)

  • Zoned (ZD)

  • Packed (PD)

  • Signed binary (FI) and unsigned binary (BI)

Comparison operators

  • Equals (EQ)

  • Different (NE)

  • Greater (GT)

  • Greater or equals (GE)

  • Lower (LT)

  • Lower or equals (LE)

Inrec and Outrec Cards

The record formatting in inrec and outrec cards only supports DFSORT “BUILD” syntax with the following elements:

  • Fields copy (with the same supported formats as for sort cards).

  • Character string constants (“C'…'”).

  • Hexadecimal constants (“X'…'”).

  • Space constants (“X”).

  • Numeric editing patterns, including predefined masks ("M0" to "M26"). Signs ("SIGN=") and length ("LENGTH=") statements are supported.