TSO-ISPF JCL COBOL VSAM DB2 CICS IMS-DB Tools Articles Forum Quiz Interview Q&A

JCL - DFSORT Overview


DFSORT is a program you use to sort, merge, and copy information.

  • When you sort records, you arrange them in a particular sequence, choosing an order more useful to you than the original one.

  • When you merge records, you combine the contents of two or more previously sorted data sets into one.

  • When you copy records, you make an exact duplicate of each record in your data set.

Merging records first requires that the input data sets are identically sorted for the information you will use to merge them and that they are in the same order required for output. You can merge up to 100 different data sets at a time.

In addition to the three basic functions, you can perform other processing simultaneously:

1. You can control which records to keep in the final output data set.

2. You can parse, edit, and reformat your records before or after other processing.

3. You can sum numeric information from many records into one record.

4. You can create one or more output data sets for a sort, copy, or merge application.

5. You can perform various "join" operations on two files by one or more keys.


JCL Sort structue is as follows--

//STEP001   EXEC PGM=SORT,REGION=1024K,PARM=parameters
//SYSOUT    DD SYSOUT=*           Output messages from SORT
//SORTIN    DD DSN=...,DISP=SHR   Input if SORT request
//SORTOUT   DD DSN=...            Output for SORT request
//SORTOFxx  DD DSN=...            OUTFILE output data sets
//SORTXSUM  DD DSN=...            Output eliminated by the SUM stm
//SORTWKnn  DD UNIT=SYSDA,        Work files if SORT request
//SYSIN     DD *                  Control statement input data set
   sort control statements
/*

Listed below the processing order of the sort control statements:

  1. SORTIN

  2. SKIPREC

  3. INCLUDE/OMIT

  4. STOPAFT

  5. INREC

  6. SORT/SUM or COPY

  7. OUTREC

  8. OUTFIL

  9. SORTOUT


SORTIN - Input record

SKIPREC=n causes sort to skip over 'n' records in the input file before starting a sorting or copying operation.

INCLUDE - Include to the record for further process; OMIT - Exclude the record for further processinh

STOPAFT=n causes sort to stop after 'n' records in the input file have been sorted or copied.

INREC - It allows you to reformat the input records before they are sorted, merged, or copied.

SORT - Sort the record; SUM - Remove duplicate or sum the fields; COPY - copy the record.

OUTREC - It allows you to reformat the input records after they are sorted, merged, or copied.

OUTFIL - It allows you to create one or more output data sets.

SORTOUT - Output record


We wil see each sort control statements with examples in next chapter...


If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal