Inserting blanks

If an output data set contains only character data, you can print it by writing the SORTOUT DD statement as follows:

//SORTOUT DD SYSOUT=A

You can make the printout more readable by using the OUTREC statement to separate the fields with blanks and to create margins. You can insert blanks before, between, or after fields. You can use X or 1X to specify a single blank. You can use nX to specify n blanks.

For example, assume you want to print just the publisher and title fields, with the publisher field appearing first. Because most of the publishers’ names fill up the entire 4-byte publisher field, the publishers’ names will run into the titles if you do not separate the two fields with blanks. Also, without a margin, the publishers’ names will begin at the edge of the paper.

The printout can be made more readable by creating a left margin of 20 blanks and by separating the fields with 10 blanks.

To insert 20 blanks, write 20X before the first field. To insert 10 blanks, write 10X between the two fields. The SORT statement sorts the records by title in ascending order (remember that SORT, COPY, or MERGE is always required).

   SORT FIELDS=(1,75,CH,A)
   OUTREC BUILD=(20X,106,4,10X,1,75)

Table 1 shows the result.

Table 1. Output After Inserting Blanks
 
Publisher
 
Book Title
1          20
21  24
25  34
35            190
(20 Blanks)
 
FERN
FERN
WETH
COR
VALD
WETH
COR
VALD
COR
COR
COR
FERN
COR
VALD
VALD
COR
WETH
FERN
WETH
VALD
(10 Blanks)
 
ADVANCED TOPICS IN PSYCHOANALYSIS
COMPUTER LANGUAGES
COMPUTERS: AN INTRODUCTION
CRISES OF THE MIDDLE AGES
EDITING SOFTWARE MANUALS
EIGHTEENTH CENTURY EUROPE
INKLINGS: AN ANTHOLOGY OF YOUNG POETS
INTRODUCTION TO BIOLOGY
INTRODUCTION TO PSYCHOLOGY
LIVING WELL ON A SMALL BUDGET
MODERN ANTHOLOGY OF WOMEN POETS
NUMBERING SYSTEMS
PICK’S POCKET DICTIONARY
SHORT STORIES AND TALL TALES
STRATEGIC MARKETING
SUPPLYING THE DEMAND
SYSTEM PROGRAMMING
THE COMPLETE PROOFREADER
THE INDUSTRIAL REVOLUTION
VIDEO GAME DESIGN
If you know the columns you want your fields to start in, you can specify them directly instead of figuring out how many blanks to use. For example, if you want the publisher field to start in column 21 and the title field to start in column 35, as shown previously, you can write the OUTREC statement as:
  OUTREC BUILD=(21:106,4,35:1,75)

c: causes DFSORT to fill in blanks from the last field with data (or column 1) up to the column before c. So 21: puts blanks in columns 1-20 and 35: puts blanks in column 25-34.

Specifying c:X as your last field is an easy way to increase the record length of your output records to c bytes. For example, if you want to create 80-byte output records containing the first 30 bytes of your input records padded with blanks, you can use this OUTREC statement:
  OUTREC BUILD=(1,30,80:X)

DFSORT automatically sets LRECL=80 for the SORTOUT data set if you do not override the LRECL.