Coding DFSORT procedure statements

If you want to use DFSORT statements in a procedure, then the first line in the procedure must contain the string *FASTPROC coded in column one. You must then code your DFSORT statements in the subsequent lines, prior to any REXX statements. DFSORT statements are coded in columns 1-71.

File Manager supports only the following DFSORT statements:

  • INCLUDE/OMIT
  • INREC
  • OUTREC
  • OUTFIL

No other DFSORT statements are supported, except that DFSORT format comment statements can be interspersed with the DFSORT statements. These statements have an asterisk (*) in column 1; they are ignored by File Manager and are not listed in any output.

You can use the DFSORT INCLUDE and OMIT statements to conditionally select records, INREC and OUTREC statements to reformat data, and OUTFIL statements to write to data sets in addition to the primary output data set. This eliminates the need for REXX processing in many basic scenarios.

The DFSORT statements and the output from DFSORT are only displayed if an error is detected. However, if a listing of the DFSORT control statements and output are especially required, the following File Manager control statement can be used in a batch job:
$$FILEM SHOWSORT
This must be placed as the first File Manager control statement. The output is written to the SYSPRINT data set.

For general information about writing DFSORT statements and for the details of DFSORT statement syntax, see the DFSORT Application Programming Guide.

Pay particular attention to the following points:

DFSORT labels
DFSORT syntax allows a statement label to be coded in column one. This means that operation keywords (such as INCLUDE) must not begin before column two.
DFSORT keywords
DFSORT keywords must be coded in upper case.
Statement continuation
Statements ending with a comma or semicolon are concatenated with the next statement at the first non-blank character.

Statements with a non-blank character in column 72 are concatenated with the next statement. All blanks up to and including column 71 are included in the concatenated statement.

Note: These continuation rules are specific to File Manager, and are a little different from the standard DFSORT statement continuation rules. If you are using DFSORT statements coded for use with the DFSORT product, you might need to modify them to use them in a File Manager procedure.
Specifying data positions in variable-length records
Data positions in DFSORT control statements that refer to variable-length records must allow four extra bytes for the record descriptor word (RDW) preceding the data. For example, the following INCLUDE statement for a fixed-length record:
INCLUDE COND=(1,2,CH,EQ,'01')

becomes:

INCLUDE COND=(5,2,CH,EQ,'01')

for a variable-length record.

When File Manager uses DFSORT to process records, all VSAM data sets, except for fixed-length relative record data sets (RRDS's), are treated as variable-length. Non-VSAM data sets are treated as fixed or variable-length, according to the data set specifications.

Using OUTFIL statements
When using OUTFIL statements to write multiple output files, direct one of them to the same file as the File Manager output so any data not needed for the OUTFIL data sets is discarded (see Copying data for an example).

The following examples demonstrate some simple DFSORT statements.

Example 1
To include all records where columns 1-4 contain the name FRED.
*FASTPROC
 INCLUDE COND=(1,4,CH,EQ,C'FRED')
Example 2
To process only those records where columns 1-80 are not all blank.
                                                                  col 72
*FASTPROC
 OMIT COND=(1,80,CH,EQ,C'                                              X
                                  ')