DFSORT Reformatting with fixed fields

DFSORT SUM: Handling overflow - NOVLSHRT DFSORT OUTREC: Inserting data


This topic describes how therecords with fixed fields reformatted.

Reformat records can be done in data sets by using the INREC, OUTREC, andOUTFIL control statements.

INREC, OUTREC, andOUTFIL control statements can be used separately or together.

Using INREC, OUTREC, and OUTFIL, the below list of tasks can be performed while sorting, copying, or merging, including:

  • Delete fields.
  • Reorder fields.
  • Insert separators like blanks, zeros, strings, current date, future date, past date, and current time.
  • Translate data from uppercase to lowercase, lowercase to uppercase, EBCDIC toASCII and ASCII to EBCDIC.
  • Translate data to hexadecimal and bit representation.
  • Convert date fields from one data type to another data type.
  • Convert numeric values to different types which also printable with or without thousands separators, decimal point, leading or suppressed zeros and signs.
  • Convert numeric values from one format to another format.
  • Perform arithmetic operations using numeric values and decimal constants.
  • Perform arithmetic operations on date fields.
  • Change values using a lookup table.
  • Replace or remove data using find and replace operations.
  • Insert sequence numbers.
  • Left-justify data, right-justify data, left-squeeze data, and right-squeeze data.
  • Perform various operations on groups of records.

Reformat records can be done in one of the following ways:


Reformat each record by specifying all of its items one by one.

Buildgives full control over the items that required in reformatted recordsand the order in which they appear.

User can delete, rearrange and insert fieldsand constants by using BUILD.


Reformat each record by specifying the items that overlayspecific columns.


Reformat each record by doing various types of finds and replaceoperations.

IFTHEN clauses:

Reformat different records in different ways.

Reformat records by specifying howto build, overlay, find/replace, or group operation items.

The INREC, OUTREC, and OUTFIL statements perform almost all same functions.

The INREC statement reformats records before they are sorted, copied ormerged.

The OUTREC statement reformats records after they are sorted, copied ormerged.

The OUTFIL statement can reformat records afterthey are sorted, copied or mergedfor OUTFIL output data sets. Different reformatting parameters can beused for different OUTFIL data sets.

Note: For INREC and OUTREC, either the BUILD parameter or theFIELDS parameter can be used. For OUTFIL, either the BUILD parameter or theOUTREC parameter can be used.

Reformatting records after sorting with BUILD or FIELDS

The fields which are not needed can be deleted by using the FIELDS or BUILDparameter of the OUTREC statement.


OUTREC FIELDS=(starting position of field1, length of field1,….. )

Starting position of field1Field1 starting position in the input file after sorting.
Length of feild1Field1 physical length in input file.
DFSORT SUM: Handling overflow - NOVLSHRT DFSORT OUTREC: Inserting data