DFSORT: Taming Wild and Unruly Data

5 Pages

OVERLAY is used in the INREC statement to operate on the name values in columns one through 12; no other fields are affected.

OVERLAY is used in the OUTREC statement to operate on the change values in columns 23 through 34 and on the id values in columns 35 through 44. No other fields are affected. The output column indicates the start of the field to be overlaid; 23: is used for the start of the change field and 35: is used for the start of the id field. If an output column isn’t specified, it defaults to 1:, so 1: isn’t needed for the start of the name field.

Build Records (BUILD)

OVERLAY is one of three ways you can reformat records. The other two are BUILD, which lets you reformat each record by specifying all its items one by one, and IFTHEN clauses, which let you reformat different records in different ways. A future article will discuss IFTHEN clauses.

BUILD is an alias for the old FIELDS parameter of the INREC and OUTREC statement, and for the old OUTREC parameter of the OUTFIL statement. If you get in the habit of using BUILD for the INREC, OUTREC and OUTFIL statements, you won’t have to remember which uses FIELDS and which uses OUTREC.

BUILD is used in the second OUTFIL statement to create the CSV output records.

Left-Justify and Right-Justify (JFY)

JFY is a new parameter you can use with OVERLAY and BUILD to left-justify or right-justify data in specific columns. For a left-justified field, leading blanks are removed and the characters from the first non-blank to the last nonblank are shifted left, with blanks inserted on the right if needed. For a right-justified field, trailing blanks are removed and the characters from the last non-blank to the first non-blank are shifted right, with blanks inserted on the left if needed. Optionally:

  • Specific leading and trailing characters can be changed to blanks before justifying begins
  •  A leading string or a trailing string can be inserted
  • The output length can be changed (it’s equal to the input length by default). The syntax for justify is: p,m,JFY=(options), where p and m are the starting position and length, respectively, of the field to be justified, and options are specific keyword parameters you can use with JFY as follows:
  • SHIFT=LEFT or SHIFT=RIGHT: indicates whether the field is to be left-justified or right-justified
  • LENGTH=n: the output length as 1-32752
  • PREBLANK=list: a list of one to 10 characters to be replaced with blanks before DFSORT starts to justify the data. For example, PREBLANK=C’+-’ or PREBLANK=X’4E60’ replaces each ‘+’ or ‘-’ character with a blank before justifying. Pre-blanked characters are treated the same as blanks.
  • LEAD=string: a one- to 50-byte character or hexadecimal string to be inserted to the left of the first nonblank character.
  • TRAIL=string: a one- to 50-byte character or hexadecimal string to be inserted to the right of the last nonblank character.

JFY is used in the INREC statement to left-justify the name values. As a result, the first non-blank character of each name will start in column one. Each name will be padded on the right with blanks up to column 12, as needed.

Signed Free Form Format (SFF)

5 Pages