DFSORT Processing


DFSORT processing can be devided into two types based on its processing ways.

  1. Sorting or Copying
  2. Merging

Sorting or copying -


The below diagram shows the detail process of DFSORT processing when using it for sorting or copying.

Processing

Merging -


The below diagram shows the detail process of DFSORT processing when using it for merging.

Processing

Process -


The below steps provides detail information about how the SORT processes a specific request with all its options and the order of the options processing.

  1. As a first step DFSORT verifies SORTIN data set provided for SORT or COPY jobs. Similarly SORTINnn data sets for MERGE jobs. If SORTIN data exists, DFSORT reads the input records and processes it based on conditions. If no SORTIN data set is present for SORT or COPY, the records needs to be supplied by cobol user exit( E15 for sorting or copying and E32 for Merging).
  2. If input records for SORT or COPY are read from a SORTIN data set, DFSORT starts processing specified with the SKIPREC option. DFSORT starts processing SKIPREC if specified and logically deletes records until the SKIPREC count is satisfied.
  3. If the input records for SORT or COPY are read from a SORTIN data set, DFSORT checks for specified E15 user exit. If exists, DFSORT transfers control to the user exit routine.
  4. DFSORT starts processing INCLUDE or OMIT statement if specified.
  5. For SORT or COPY, DFSORT starts processing with the STOPAFT option if specified.
  6. DFSORT starts processing an INREC statement if specified.
  7. DFSORT starts processing the SORT, MERGE, or OPTION COPY statement specified.
    • For SORT, all input records are processed by default before any output record is processed.
    • For COPY or MERGE, an output record is processed after an input record is processed.
    • For SORT or MERGE, if SUM statement is specified, it will be processed during the SORT or MERGE.
  8. DFSORT starts processing an OUTREC statement if specified.
  9. If an E35 user exit is present, DFSORT transfers control to user exit routine after all statement processing (except OUTFIL) is completed.
  10. DFSORT writes records to the SORTOUT data set at the end, if present.
  11. DFSORT starts processing one or more OUTFIL statements if specified.
    • DFSORT starts processing with the STARTREC, SAMPLE, and ENDREC options if specified.
    • DFSORT starts processing with the INCLUDE, OMIT, or SAVE option if specified.
    • DFSORT starts processing with the ACCEPT option if specified. Record processing ends when ACCEPT limit is reached.
    • Data records are parsed, edited, reformatted, converted and repeated according to the options specified by using the PARSE, OUTREC, OVERLAY, FINDREP, IFTHEN, FTOV, VTOF (or CONVERT), VLFILL, VLTRIM, VLTRAIL and REPEAT options if specified.
    • Data records are reformatted and reports are generated for the OUTFIL data sets by using the LINES, HEADER1, TRAILER1, HEADER2, TRAILER2, SECTIONS, NODETAIL, BLKCCH1, BLKCCH2, BLKCCT1 and REMOVECC options if specified.
    • Records are distributed among the OUTFIL data sets as evenly as possible by using SPLIT, SPLITBY, or SPLIT1R processing if specified.
    • DFSORT writes OUTFIL records to the appropriate OUTFIL data sets.