The sort program is used to sort data into a desired sequence
based on business requirement. Also, it can be used to merge many files into one single file.
Example of a JCL representation
Features of the SYNCSORT utility
- Copy Function
- Merge function capable of merging up to 32 data sets into one sequence provided those data sets are sorted. Latest versions allow up to 100 data sets to be merged.
- Sort facility which can sort single or concatenated data sets into one data set.
- Conversion of the packed decimal fields to printable formats.
- Designing of reports
SYNCSORT invocation
- The SYNCSORT is invoked through a JCL
- As a sub-program (in COBOL or PL/1) from a main program
THE JCL Description
1. SORTIN DD
Input file can be:
- PDS Member
- PS sequential file
- VSAM( KSDS,ESDS or RRDS)
- Concatenated File but should be of same record length
- For Record Format (RECFM) being Variable the file of largest record length and block size if input data sets should be used
- DSB information not be supplied for a disk or standard labelled tape file.
Example of JCL representation (single file)
//SORTIN DD DSN= DATA1.FILE ,DISP=(OLD,KEEP),
UNIT=TAP38,VOL=SER=10699
Example of JCL representation (concatenated files)
//SORTIN DD DSN= DATA1.FILE,DISP=(OLD,KEEP),
// UNIT=TAP1,VOL=SER=10699,
//
DCB= (LRECL=200,RECFM=FB,BLKSIZE=7404
//
DD DSN= DATA2.FILE,DISP=(OLD,KEEP),
// UNIT=TAP1,VOL=SER=10222
//
DD DSN= DATA3.FILE,DISP=(OLD,KEEP),
// UNIT=TAP1,VOL=SER=10324
SORTINn DD and
SORTINnn are used for merging data sets and the files must themselves be sorted
and should be of the same record format.
The valid range of 'n' is from 0 to 9 whereas for 'nn' it is 00 to 99 .
Example of JCL representation (merge application)
//SORTIN00 DD
DSNAME=DATA4.FILE ,VOL=SER=44444,
// DISP=OLD,UNIT=TAP1
//SORTIN01 DD DSNAME=DATA5.FILE ,VOL=SER=41235,
// DISP=OLD,UNIT=TAP1
//SORTIN02 DD DSNAME=DATA6.FILE ,VOL=SER=47876,
// DISP=OLD,UNIT=TAP1
……… and so on.
Here there is no
need to supply the DCB information.
2. SORTOUT DD
This is the output file for the SORT,MERGE or COPY functions and can be any one of the
input file types .
Example of a JCL representation
//SORTOUT DD DSN=MASTER.OUT,
//
DISP=(,CATLG,DELETE),
//
UNIT=SYSDA,SPACE=(CYL(100,20),RLSE)
The DCB Parameters expcept
BLKSIZE for the output file will be of the sortin file.
For a merge application the DCB parameters will be the one
specified to the first SORTINnn file in the JCL stream.
SORTXSUM DD is the output
file that will contain the records eliminated or discarded by SUM processing.
SORTWKnn DD: Upto 32 data sets (sort work files) can be allocated.
Each SORTWKnn must be allocated on a single unit and a single volume.
Example : //SORTWK02 DD
UNIT=3380,SPACE=CYL,20
These SORTWKnn are not required for merge, copy application and
when the sort is executing using
DYNALLOC option .
SORTOFxx and SORTOFx are the other statements used to define one
or more output files.
Note:
FDR(First Data Resource) has it's own
built-in utility known as FDRSORT which overcomes this problem as it
dynamically allocates the necessary sort work space by estimating the number of
input records into sort. But this utility cannot be used on a PDS and VSAM
file.
3. SYSIN DD
SYSIN can be given as control card/file or directly sort
statements.
An example is shown below :
Example : //SYSIN
DD *
SORT FIELDS = (2,4,CH,A)
INCLUDE
COND = (15,4,CH,EQ,C'5630')
/*
4. SYSOUT
This data set contains all the sort messages .
The sort messages can be seen in spool by following statement:
//SYSOUT DD SYSOUT=* (no
data set specified ) .
If you need in dataset, give DSN name instead of SYSOUT.The
messages are put in the same msgclass as specified in the job card .
Other DD statements
includes $ORTPARM , SORTCKPT , SORTMODS , SYSLIN , SYSLMOD, SYSPRINT(Defines
the message data set for the link-editing of sort exits).
Good info. For more sample jobs on SORT refer
ReplyDeletehttp://clearmainframeinterview.blogspot.in/search/label/SORT
Sreenivas,
http://clearmainframeinterview.blogspot.in/search/label/SORT