SORT
The SORT program is used to sort data into a certain sequence or to merge from 2 to 100 previously sorted input data sets into 1 output data set.
//STEP10 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=<< INPUT FILE NAME >>
//SORTOUT DD DISP=(MOD,CATLG,DELETE),SPACE=(CYL,(5,5),RLSE),
// UNIT=SYSDA,DCB=*.SORTIN,
// DSN=<< OUTPUT FILE NAME >>
//SYSIN DD *
//************** INCLUDE SORT STEPS HERE
1) TO SORT ON POSITIONS say for eg. 1 to 7
SORT FIELDS=(1,7,CH,A)
Where
Sort fields = (position ,length ,format ,sequence) or
Sort fields = (position ,length , sequence..),format = CH/BI/PD/ZD.d
PD=packed Decimal(COMP-3), ZD=zone decimal.
NOTE :-
Instead of using JCL to perform SORT operation , there's one simple alternative,
For eg:- Open a Flat file in edit mode. On the command line type (say) SORT 1,7 and press ENTER, the file will be sorted on positions 1 to 7 bytes.
2) TO COPY ALL THE RECORDS FROM INPUT FILE TO OUTPUT FILE
SORT FIELDS=COPY
3) TO COPY THOSE RECORDS WHICH SATISFY A PARTICULAR CONDITION.
INCLUDE COND=(38,10,CH,EQ,C'57071509',OR,36,10,CH,EQ,C' 57105779')
4) TO OMIT THOSE RECORDS WHICH SATISFY A PARTICULAR CONDITION.
OMIT COND=(19,1,CH,EQ,C'S',OR,19,1,CH,EQ,C'S')
5) TO SKIP CERTAIN NO OF RECORDS
SORT FIELDS=COPY,SKIPREC=1000
6) TO STOP AFTER COPYING CERTAIN NO OF RECORDS
SORT FIELDS=COPY,STOPAFT=5000
7) SKIPREC AND STOPREC CAN BE USED IN COMBINATION
SORT FIELDS=COPY,SKIPREC=1000,STOPAFT=5000
8) TO REMOVE DUPLICATES FROM THE FILE USING SORT
SORT FIELDS=(1,7,A),FORMAT=CH
SUM FIELDS=NONE
Saturday, July 11, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment