DFSORT: Taming Wild and Unruly Data

5 Pages

Suppress Page Eject for Trailer (BLKCCT1)

BLKCCT1 is a new parameter you can use on OUTFIL statements to avoid forcing a page eject at the start of the report trailer described by the TRAILER1 parameter; the ANSI carriage control character of “1” (page eject) in the first line of the report trailer is replaced with a blank. BLKCCT1 is used in the first OUTFIL statement. So the entire report appears on one page. Without BLKCCT1, the first line of the report trailer (the line with asterisks) would have a “1” carriage control instead of a blank carriage control and would start on a new page.

You also can use these other OUTFIL parameters to affect the ANSI carriage control characters:

  • REMOVECC: Removes all the ANSI carriage control characters.
  • BLKCCH1: Avoids forcing a page eject at the start of the report header described by the HEADER1 parameter.
  • BLKCCH2: Avoids forcing a page eject at the start of the first page header (but not for the second and subsequent page headers).

Left-Squeeze and Right-Squeeze (SQZ)

SQZ is a new parameter you can use with OVERLAY and BUILD to leftsqueeze or right-squeeze data in specific columns. For a left-squeezed field, all 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-squeezed field, all 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 characters can be changed to blanks before squeezing begins
  • A leading string or a trailing string can be inserted
  • A string can be inserted wherever a group of blanks is removed
  • Blanks can be kept intact between paired apostrophes or paired quotes
  • The output length can be changed (it’s equal to the input length by default).

The syntax for squeeze is: p,m,SQZ=(options) where p and m are the starting position and length, respectively, of the field to be squeezed, and options are specific keyword parameters you can use with SQZ as follows:

  • SHIFT=LEFT or SHIFT=RIGHT: indicates whether the field is to be left-squeezed or right-squeezed.
  • 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 squeeze the data.

For example, PREBLANK=C’+-’ or PREBLANK=X’4E60’ replaces each ‘+’ or ‘-’ character with a blank before squeezing. 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.
  • MID=string: a one- to 10-byte character or hexadecimal string to be inserted wherever one or more blanks are squeezed out between the first non-blank and the last non-blank.
  • TRAIL=string: a one- to 50-byte character or hexadecimal string to be inserted to the right of the last nonblank character.
  • PAIR=APOST: indicates blanks between apostrophe pairs (example: ‘AB C DE’) should not be squeezed out.
  • PAIR=QUOTE: indicates blanks between quote pairs (example: “AB C DE”) should not be squeezed out. SQZ is used in the second OUTFIL statement to create the CSVs from the fixed values. SHIFT=LEFT squeezes characters to the left. PREBLANK=C’+’ replaces each plus sign in the amount1 and amount2 values with a blank to squeeze it out. LEAD=C’”’ inserts a quote before each name value. MID=C’”,”’ inserts quote/comma/quote between the name and amount1 values, between the amount1 and amount2 values, and between the amount2 and id values. TRAIL=C’”’ inserts a quote after each id value with no intervening blanks. Each resulting record has the form “name”,”amount1”, ”amount2”,”id” and is padded on the right with blanks up to column 46 as needed.

Summary

DFSORT offers many functions for dealing with various types of wild and unruly data. By using the techniques discussed here, you can tap into those features to produce correctly sorted records, readable data in fixed columns, delimited data, and much more. Future articles will discuss additional DFSORT functions you can use. Z

5 Pages