Using other statements with INREC
Because INREC reformats the records before they are sorted, the SORT and SUM statements must refer to the reformatted records as they will appear in the output data set.
Thus, after INREC, the input records for the control statement in the previous section are 12 bytes long (see Table 2 for an example).
* Move input positions 106-109 to reformatted record positions 1-4.
* Move input positions 162-169 to reformatted record positions 5-12.
INREC FIELDS=(106,4,162,8)
* Sort reformatted record positions 1-4.
SORT FIELDS=(1,4,CH,A)
* Sum reformatted record positions 5-8 and 9-12.
SUM FIELDS=(5,4,BI,9,4,BI)Table 1 shows the result.
Publisher |
Number
In Stock |
Number
Sold |
|---|---|---|
1 4
|
5 8
|
9 12
|
COR
FERN VALD WETH |
103
19 42 62 |
161
87 97 79 |
As the flowchart in Processing order of control statements shows, DFSORT processes the INREC statement before SORT, SUM, and OUTREC, but after INCLUDE and OMIT. Therefore, when used with the INREC statement, SORT, SUM, and OUTREC must refer to the reformatted records, and INCLUDE and OMIT must refer to the original records.
DFSORT processes the OUTFIL statements after the INREC and OUTREC statements. Therefore, OUTFIL must refer to the reformatted records produced by OUTREC if specified, or to the reformatted records produced by INREC if it is specified without OUTREC. You will learn about OUTFIL statements in Creating multiple output data sets and reports.
INCLUDE COND=(110,5,CH,EQ,C'ENGL',OR,110,5,CH,EQ,C'PSYCH')
INREC FIELDS=(1:1,75,76:170,4,80:110,5)
SORT FIELDS=(76,4,BI,D)
OUTREC FIELDS=(1:1,75,85:76,4,BI,EDIT=($IT.TT),95:80,5)
OUTFIL FNAMES=ENGL,INCLUDE=(95,5,CH,EQ,C'ENGL')
OUTFIL FNAMES=PSYCH,INCLUDE=(95,5,CH,EQ,C'PSYCH')The INCLUDE and INREC statements refer to fields as they appear in the input records. The SORT and OUTREC statements refer to fields as they appear in the reformatted INREC records. The OUTFIL statements refer to fields as they appear in the reformatted OUTREC records.