SORTING RECORDS IN JCL
CANAT.SAJID.JCLLIB(SORT)
-------------------------------------------------------------------------
//MTMS586C JOB 'SORT',MSGCLASS=X,CLASS=B,NOTIFY=&SYSUID
//*******************************************************
//* SORT JCL
//*******************************************************
//STEP010 EXEC PGM=SORT
//SORTWK01 DD UNIT=WORK,SPACE=(CYL,(05,05),RLSE)
//SORTIN DD DSN=CANAT.MTMS586.TEST,DISP=SHR
//SORTOUT DD DSN=CANAT.MTMS586.TEST.SORT,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(CYL,(05,05),RLSE),
// UNIT=DISK
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(15,05,CH,A)
//
//*******************************************************
//*SORT FIELDS=(POSITION,LENGTH,DATATYPE,ORDER)
//*SORT FIELDS=(01,05,CH,A,15,05,CH,A)
//* DATATYPE -- CH CHARACTER
//* -- BI BINARY
//* ORDER -- A ASCENDING
//* -- B DESCENDING
//*******************************************************
//*SORT FIELDS=COPY -- WILL COPY INPUT-FILE AS IT IS WITHOUT SORTING
//*******************************************************
-------------------------------------------------------------------------
CANAT.SAJID.JCLLIB(SORTDUP)
-------------------------------------------------------------------------
//MTMS586C JOB 'SORT DUP',MSGCLASS=X,CLASS=B,NOTIFY=&SYSUID
//*******************************************************
//* SORT INPUT FILE, DUPLICATES INTO OUTPUT FILE
//*******************************************************
//STEP010 EXEC PGM=SORT
//SORTWK01 DD UNIT=WORK,SPACE=(CYL,(05,05),RLSE)
//SORTIN DD DSN=CANAT.MTMS586.DATA,DISP=SHR
//SORTOUT DD DSN=CANAT.MTMS586.DATA.SORT,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(CYL,(05,05),RLSE),
// UNIT=DISK
//SORTXSUM DD DSN=CANAT.MTMS586.DATA.DUP,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(CYL,(05,05),RLSE),
// UNIT=DISK
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,3,CH,A)
SUM FIELDS=NONE,XSUM
//
//*******************************************************
//*SUM FIELDS=NONE -- WILL ELIMINATE THE DUPLICATES
//*SUM FIELDS=NONE,XSUM -- WILL COPY ELIMINATED RECORDS INTO A FILE
//*******************************************************
-------------------------------------------------------------------------
CANAT.SAJID.JCLLIB(SORTFILE)
-------------------------------------------------------------------------
//MTMS586C JOB 'SORT FILES',MSGCLASS=X,CLASS=B,NOTIFY=&SYSUID
//*******************************************************
//* SORT JCL
//*******************************************************
//STEP010 EXEC PGM=SORT
//SORTWK01 DD UNIT=WORK,SPACE=(CYL,(05,05),RLSE)
//SORTIN DD DSN=CANAT.MTMS586.DATA,DISP=SHR
//SORTOF01 DD DSN=CANAT.MTMS586.DATA.SORT01,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(CYL,(05,05),RLSE),
// UNIT=DISK
//SORTOF02 DD DSN=CANAT.MTMS586.DATA.SORT02,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(CYL,(05,05),RLSE),
// UNIT=DISK
//SORTOF03 DD DSN=CANAT.MTMS586.DATA.SORT03,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(CYL,(05,05),RLSE),
// UNIT=DISK
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FILES=01,INCLUDE=(1,6,CH,EQ,C'MOHANK')
OUTFIL FILES=02,INCLUDE=(1,6,CH,EQ,C'SURESH')
OUTFIL FILES=03,INCLUDE=(1,6,CH,EQ,C'KRISHN')
//
-------------------------------------------------------------------------
CANAT.SAJID.JCLLIB(SORTINCL)
-------------------------------------------------------------------------
//MTMS586S JOB 'SORT',MSGCLASS=X,CLASS=B,NOTIFY=&SYSUID
//*******************************************************
//* SORT JCL FOR INCLUDE
//*******************************************************
//STEP010 EXEC PGM=SORT
//SORTWK01 DD UNIT=WORK,SPACE=(CYL,(05,05),RLSE)
//SORTIN DD DSN=CANAT.MTMS586.DATA,DISP=SHR
//SORTOUT DD DSN=CANAT.MTMS586.DATA.SORT,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(CYL,(05,05),RLSE),
// UNIT=DISK
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(1,6,CH,EQ,C'MOHANK')
//
//*******************************************************
//* HERE WE CAN SORT THE FILE "SORT FIELDS=(P,L,DT,ORD)"
//*******************************************************
//*INCLUDE COND=(1,6,SS,EQ,C'MOHANK,SURESH')
//* SS -- SUBSTRING SEARCH
//* INCLUDE COND=(1,6,CH,EQ,C'MOHANK',OR,
//* 1,6,CH,EQ,C'SURESH')
//*******************************************************
-------------------------------------------------------------------------
CANAT.SAJID.JCLLIB(SORTINRC)
-------------------------------------------------------------------------
//MTMS586S JOB 'SORT INREC',MSGCLASS=X,CLASS=B,NOTIFY=&SYSUID
//*******************************************************
//* SORT JCL FOR INREC *
//* INPUT FILE REFORMATTED AS OUTPUT-FILE *
//*******************************************************
//STEP010 EXEC PGM=SORT
//SORTWK01 DD UNIT=WORK,SPACE=(CYL,(05,05),RLSE)
//SORTIN DD DSN=CANAT.MTMS586.DATA,DISP=SHR
//SORTOUT DD DSN=CANAT.MTMS586.DATA.SORT,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(CYL,(05,05),RLSE),
// UNIT=DISK
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC FIELDS=(7:2,5,20:10,3)
//
//*******************************************************
//* INREC FIELDS=(OUT-POS:INP-POS,INP-LEN)
//*******************************************************
//* -> TO REFORMAT THE INPUT-FILE
//* E.G.: SORT FIELDS=COPY
//* INREC FIELDS=(7:2,5,20:10,3)
//* NOTE: SORTING IS NOT DONE HERE
//*******************************************************
//* -> TO HAVE OUTPUT FILE IN SORTED ORDER
//* -> FIRST REFORMAT THEN SORT AS BELOW
//* E.G.: INREC FIELDS=(7:2,5,20:10,3)
//* SORT FIELDS=(7,5,CH,A)
//*******************************************************
-------------------------------------------------------------------------
CANAT.SAJID.JCLLIB(SORTOMIT)
-------------------------------------------------------------------------
//MTMS586S JOB 'SORT OMIT',MSGCLASS=X,CLASS=B,NOTIFY=&SYSUID
//*******************************************************
//* SORT JCL FOR INCLUDE
//*******************************************************
//STEP010 EXEC PGM=SORT
//SORTWK01 DD UNIT=WORK,SPACE=(CYL,(05,05),RLSE)
//SORTIN DD DSN=CANAT.MTMS586.DATA,DISP=SHR
//SORTOUT DD DSN=CANAT.MTMS586.DATA.SORT,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(CYL,(05,05),RLSE),
// UNIT=DISK
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OMIT COND=((1,6,CH,EQ,C'MOHANK',OR,1,6,CH,EQ,C'SURESH'))
//
//*******************************************************
//* HERE WE CAN SORT THE FILE "SORT FIELDS=(P,L,DT,ORD)"
//*******************************************************
-------------------------------------------------------------------------
CANAT.SAJID.JCLLIB(SORTOUTR)
-------------------------------------------------------------------------
//MTMS586S JOB 'SORT OUTREC',MSGCLASS=X,CLASS=B,NOTIFY=&SYSUID
//*******************************************************
//* SORT JCL FOR OUTREC *
//*******************************************************
//STEP010 EXEC PGM=SORT
//SORTWK01 DD UNIT=WORK,SPACE=(CYL,(05,05),RLSE)
//SORTIN DD DSN=CANAT.MTMS586.DATA,DISP=SHR
//SORTOUT DD DSN=CANAT.MTMS586.DATA.SORT,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(CYL,(05,05),RLSE),
// UNIT=DISK
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(7:2,5,20:10,3)
//
//*******************************************************
//* INREC FIELDS=(OUT-POS:INP-POS,INP-LEN)
//*******************************************************
//* -> TO REFORMAT THE INPUT-FILE
//* E.G.: SORT FIELDS=COPY
//* INREC FIELDS=(7:2,5,20:10,3)
//* NOTE: SORTING IS DONE ON INPUT-FILE
//*******************************************************
//* -> FIRST SORTING ON INPUTFILE THE REFORMATING TAKES PLACE
//* E.G.: SORT FIELDS=(7,5,CH,A)
//* INREC FIELDS=(7:2,5,20:10,3)
//*******************************************************
-------------------------------------------------------------------------
CANAT.SAJID.JCLLIB(SORTSKIP)
-------------------------------------------------------------------------
//MTMS586C JOB 'SORT SKIP',MSGCLASS=X,CLASS=B,NOTIFY=&SYSUID
//*******************************************************
//* SORT JCL
//*******************************************************
//STEP010 EXEC PGM=SORT
//SORTWK01 DD UNIT=WORK,SPACE=(CYL,(05,05),RLSE)
//SORTIN DD DSN=CANAT.MTMS586.DATA,DISP=SHR
//SORTOUT DD DSN=CANAT.MTMS586.DATA.SORT,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=80),
// SPACE=(CYL,(05,05),RLSE),
// UNIT=DISK
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,6,CH,A)
OPTION SKIPREC=3,
STOPAFT=8
//
//*******************************************************
//*OPTION SKIPREC=3, -> THIS WILL SKIP FIRST 3 RECORDS
//* STOPAFT=8 -> THIS WILL STOP SORT/COPY AFTER 8 RECORDS
//* STARTING FROM 3
//*******************************************************
//* OUTFIL STARTREC=4,ENDREC=11
//*******************************************************
//*SORT FIELDS=COPY -- WILL COPY INPUT-FILE AS IT IS WITHOUT SORTING
//*******************************************************
-------------------------------------------------------------------------
CANAT.SAJID.JCLLIB(GDG)
-------------------------------------------------------------------------
//MTMS586G JOB 'CREATE GDG FILES',MSGCLASS=X,CLASS=A,NOTIFY=&SYSUID,
// MSGLEVEL=(1,1)
//*******************************************************
//* STEP010 - DEFINE GDG FILES
//*******************************************************
//STEP010 EXEC PGM=IDCAMS,REGION=3000K
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DEFINE GDG(NAME(CANAT.SAJID.GDG.FILE) -
LIMIT(50) -
SCRATCH)
//*******************************************************
//* STEP020 - ALLOCATE DUMMY GENERATION (1ST TIME)
//*******************************************************
//DD1 DD DSN=CANAT.SAJID.GDG.FILE(+1),
// BLKSIZE=0,RECFM=FB,LRECL=80,
// DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(05,05),RLSE),
// UNIT=DISK,
// DCB=(MODEL)
-------------------------------------------------------------------------
CANAT.SAJID.JCLLIB(COBJCL)
-------------------------------------------------------------------------
//MTMS586X JOB 'SAMPLE COBJCL',MSGCLASS=X,CLASS=B,NOTIFY=&SYSUID
//STEP010 EXEC PGM=SAMPLE
//STEPLIB DD DSN=CHGMAN.CMNC.FLDS.#001457.LOD,DISP=SHR
//SYSOUT DD SYSOUT=*
//
-------------------------------------------------------------------------
CANAT.SAJID.JCLLIB(COBRW)
-------------------------------------------------------------------------
//MTMS586X JOB 'SAMPLE COBJCL',MSGCLASS=X,CLASS=B,NOTIFY=&SYSUID
//STEP010 EXEC PGM=COBRW
//STEPLIB DD DSN=CHGMAN.CMNC.CAND.#001457.LOD,DISP=SHR
//RDR010 DD DSN=CANAT.SAJID.CTLLIB(DATA),DISP=SHR
//PRT010 DD DSN=CANAT.SAJID.DATA.REPORT,
// DISP=(NEW,CATLG,DELETE),UNIT=DISK,
// SPACE=(CYL,(05,05),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSOUT DD SYSOUT=*
//