FASTSRT requirements for sort input and output files

If you specify FASTSRT but your code does not meet FASTSRT requirements, the compiler issues a message and the COBOL run time performs the I/O instead. Your program will not experience the performance improvements that are otherwise possible.

Note: The sort input and output files that is described in this topic relates to the format 1 SORT statement only.

To use FASTSRT, you must describe and process the input files to the sort and the output files from the sort in these ways:

  • You can name only one input file in the USING phrase. You can name only one output file in the GIVING phrase.
  • You cannot use an input procedure on an input file nor an output procedure on an output file.

    Instead of using input or output procedures, you might be able to use these DFSORT control statements:

    • INREC
    • OUTFILE
    • OUTREC
    • INCLUDE
    • OMIT
    • STOPAFT
    • SKIPREC
    • SUM

    Many DFSORT functions perform the same operations that are common in input or output procedures. Code the appropriate DFSORT control statements instead, and place them either in the IGZSRTCD or SORTCNTL data set.

  • Do not code the LINAGE clause for the output FD entry.
  • Do not code any INPUT declarative (for input files), OUTPUT declarative (for output files), or file-specific declaratives (for either input or output files) to apply to any FDs used in the sort.
  • Do not use a variable relative file as the input or output file.
  • Do not use a line-sequential file as the input or output file.
  • For either an input or an output file, the record descriptions of the SD and FD entry must define the same format (fixed or variable), and the largest records of the SD and FD entry must define the same record length.

If you code a RELATIVE KEY clause for an output file, it will not be set by the sort.

Performance tip: If you block your input and output records, the sort performance could be significantly improved.

QSAM requirements

  • QSAM files must have a record format of fixed, variable, or spanned.
  • A QSAM input file can be empty.
  • To use the same QSAM file for both input and output, you must describe the file using two different DD statements. For example, in the FILE-CONTROL SECTION you might code this:
    
    SELECT FILE-IN ASSIGN INPUTF.
    SELECT FILE-OUT ASSIGN OUTPUTF.
    

    In the DATA DIVISION, you would have an FD entry for both FILE-IN and FILE-OUT, where FILE-IN and FILE-OUT are identical except for their names.

    In the PROCEDURE DIVISION, your SORT statement could look like this:

    
    SORT file-name
      ASCENDING KEY data-name-1
      USING FILE-IN GIVING FILE-OUT
    

    Then in your JCL, assuming that data set INOUT has been cataloged, you would code:

    
    //INPUTF  DD DSN=INOUT,DISP=SHR
    //OUTPUTF DD DSN=INOUT,DISP=SHR
    

    On the other hand, if you code the same file-name in the USING and GIVING phrases, or assign the input and output files the same ddname, then the file can be accepted for FASTSRT either for input or output, but not both. If no other conditions disqualify the file from being eligible for FASTSRT on input, then the file will be accepted for FASTSRT on input, but not on output. If the file was found to be ineligible for FASTSRT on input, it might be eligible for FASTSRT on output.

A QSAM file that qualifies for FASTSRT can be accessed by the COBOL program while the format 1 SORT statement is being performed. For example, if the file is used for FASTSRT on input, you can access it in an output procedure; if it is used for FASTSRT on output, you can access it in an input procedure.

VSAM requirements

  • A VSAM input file must not be empty.
  • VSAM files cannot be password-protected.
  • You cannot name the same VSAM file in both the USING and GIVING phrases.
  • A VSAM file that qualifies for FASTSRT cannot be accessed by the COBOL program until the format 1 SORT statement processing is completed. For example, if the file qualifies for FASTSRT on input, you cannot access it in an output procedure and vice versa. (If you do so, OPEN fails.)

Related tasks  
DFSORT Application Programming Guide