INDIA - MAINFRAME SORT JCL INTERVIEW QUESTIONS TUTORIALS RAMESH KRISHNA REDDY



HOME  |  JCL TUTORIALS  |  DRONA TUTORIALS




DFSORT TUTORIAL
SORT JCL from DRONA SERIES

SORT A FILE | SORT SUM FIELDS NONE | SORT OUTFIL - Split data file | SORT SUM FIELDS XSUM | SORT INCLUDE | SORT INREC OUTREC | Examples


SORT JCL DISCUSSION FORUM |  ONLINE MAINFRAME TUTORIALS
SORT INCLUDE
Include Example 1
Include Example 2
SORT include date
Include date Example 1
Include date Example 2
Include - Validate Numeric Data
CHAPTER-3 SORT INREC
SORT INREC Example
SORT OUTREC - OVERLAY  Outrec2
SORT Outrec Examples
Build in SORT
ASSUMPTIONS

Before discussing about SORT,let us assume following things

Input file has following data and structure


INPUT FILE
MOHANK  23423423434534344 KIRAN 
MOHANK  13342345345345345 RAJEEV 
ARAMES  34535345325354324 SURESH 
SURESH  98347385385933987 PULI 
RAMESH  67575789769876785 MADHU 
KRISHN  50830948530859340 OIIED 
KRISHN  30495849572938495 MADHU 
SURESH  98347385385933987 PULI 
	
Simple SORT jcl structue is as follows - Sample sort jcl ---- . . //STEP10 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 /* . . FOLLOWING ARE THE SORT CARD JCLS FOR DIFFERENT TYPES OF SORTS
TASK 1. SORT A GIVEN FILE - SORT FIELDS - SAMPLE SORT JCL -
//SYSIN DD * SORT FIELDS=(1,3,CH,A,9,3,CH,A) /*
OUTPUT FILE
ARAMES  34535345325354324 SURESH 
KRISHN  30495849572938495 MADHU 
KRISHN  50830948530859340 OIIED 
MOHANK  13342345345345345 RAJEEV 
MOHANK  23423423434534344 KIRAN 
RAMESH  67575789769876785 MADHU 
SURESH  98347385385933987 PULI 
SURESH  98347385385933987 PULI 
	
EXPLANATION Above syntax of SORT sorted the recrods, depends on keys we have provided (we have provided two keys in FIELDS parameter) FIRST KEY 1,3,CH,A - first key started at col 1 , its length is 3 SECOND KEY 9,3,CH,A - second key started at col 9, its length is 3 In the above example, CH- means character we may use BI for binary A - Ascending order
TASK 2. ELEMINATE DUPLICATES - SORT JCL - SUM FIELDS
//SYSIN DD * SORT FIELDS=(1,3,CH,A) SUM FIELDS=NONE /* //** copyright www.mainframegurukul.com
OUTFILE
ARAMES  34535345325354324 SURESH
KRISHN  50830948530859340 OIIED 
MOHANK  23423423434534344 KIRAN 
RAMESH  67575789769876785 MADHU 
SURESH  98347385385933987 PULI 
	
EXPLANATION if we give SUM FIELDS=NONE it will eliminate duplicates TAGS : SORT JCL, SORT JCL SUM FIELDS NONE, ELIMINATE DUPLICATES
TASK 3. SPLIT FILE INTO TWO OR THREE FILES DEPENDS ON CONDITIONS - OUTFIL
. . . //SORTOF01 DD DSN=dataset1, // DISP=(NEW,CATLG,DELETE),UNIT=SYSDA, // SPACE=(CYL,(1,4),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0) //SORTOF02 DD DSN=dataset2, // DISP=(NEW,CATLG,DELETE),UNIT=SYSDA, // SPACE=(CYL,(1,4),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0) //SORTOF03 DD DSN=dataset3, // DISP=(NEW,CATLG,DELETE),UNIT=SYSDA, // SPACE=(CYL,(1,4),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0) . . . //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') /*
SORTOF01
MOHANK  23423423434534344 KIRAN 
MOHANK  13342345345345345 RAJEEV 
	
SORTOF02
SURESH  98347385385933987 PULI 
SURESH  98347385385933987 PULI 
	
SORTOF03
KRISHN  50830948530859340 OIIED 
KRISHN  30495849572938495 MADHU 
	
EXPLANATION 1. SORT FIELDS=COPY - indicate , it for copy of records, not for sort 2. 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') - SYNCSORT will take data from 1st positioon to 6th position of input file and it will compare that data with MOHANK or SURESH or KRISHN - If data equals to MOHANK then that recorrd will copies to dataset defined in SORTOF01 step. ( because we defined FILES=01 in second condition ) - If data equals to SURESH then that recorrd will pass to dataset defined in SORTOF02 step. ( because we defined FILES=02 in second condition ) - If data equals to KRISHN then that recorrd will copied to dataset difned in SORTOF03 step. ( because we defined FILES=03 in third condition ) SORT JCL TO SPLIT DATA USING OUTFILE - Example 2 Aim : Want to split a file contaning 700 records into 3 files where 1st file has 200, 2nd has 200 and 3rd has 300. Want to do it using JCL sort using OUTFIL We can split the files using OUTFIL option. Check below example. //*********************************************************** //SPLITFLS EXEC PGM=SORT //*********************************************************** //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //SORTIN DD DSN=FILE1......,DISP=SHR //SORTOF01 DD DSN=OUTPUTFILE1......., // DISP=(NEW,CATLG,DELETE),UNIT=SYSDA, // SPACE=(CYL,(1,1),RLSE), // RECFM=FB,LRECL=20 //SORTOF02 DD DSN=OUTPUTFILE2.............., // DISP=(NEW,CATLG,DELETE),UNIT=SYSDA, // SPACE=(CYL,(1,1),RLSE), // RECFM=FB,LRECL=20 //SORTOF03 DD DSN=OUTPUTFILE3.............., // DISP=(NEW,CATLG,DELETE),UNIT=SYSDA, // SPACE=(CYL,(1,1),RLSE), // RECFM=FB,LRECL=20 //SYSIN DD * SORT FIELDS=COPY OUTFIL FILES=01,ENDREC=200 OUTFIL FILES=02,STARTREC=201,ENDREC=400 OUTFIL FILES=03,STARTREC=401,ENDREC=700 /* TAGS : SORT JCL, SORT JCL TO SPLIT DATA FILE, SORT JCL OUTFIL, SORT JCL INCLUDE
TASK 4. COPY ELIMINATED DUPLICATES INTO ANOTHER FILE - SAMPLE SORT UTILITY JCL
. . //SORTXSUM DD DSN=datasetname, // DISP=(NEW,CATLG,DELETE),UNIT=SYSDA, // SPACE=(CYL,(1,4),RLSE), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800) . . //SYSIN DD * SORT FIELDS=(1,3,CH,A) SUM FIELDS=NONE,XSUM /* //*copyright www.mainframegurukul.com & www.geocitie.comhttp://www.mainframegurukul.com/srcsinc
SORTOUT
ARAMES  34535345325354324 SURESH 
KRISHN  50830948530859340 OIIED 
MOHANK  23423423434534344 KIRAN 
RAMESH  67575789769876785 MADHU 
SURESH  98347385385933987 PULI 
	
SORTXSUM
KRISHN  30495849572938495 MADHU 
MOHANK  13342345345345345 RAJEEV
SURESH  98347385385933987 PULI 
	
EXPLANATION 1. SORT FIELDS=(1,3,CH,A) Input file will be sorted depending up on the key specified above 1,3,CH,A - key starting position is 1 and length 3, comparing type character, sorting is don in ascending order 2. SUM FIELDS=NONE,XSUM SUM FIELDS=NONE means it will eliminate duplicates XSUM options will copy all records eliminated in sort process will copy to another data set defined in SORTXSUM step TAGS : SORT JCL, SORT JCL TO COPY DUPLICATES INTO ANOTHER FILE, SORT JCL SUM FIELDS XSUM OPTION.
TASK 5. COPY RECORDS DEPENDING UPON CONDITION - INCLUDE IN SORT JCL
//SYSIN DD * SORT FIELDS=COPY INCLUDE COND=(1,6,CH,EQ,C'SURESH') /* //* copyright www.mainframegurukul.com
OUTPUTFILE
SURESH  98347385385933987 PULI 
SURESH  98347385385933987 PULI 
	
EXPLANATION above card is to copy records from input file which contains SURESH at 1st position TAGS : SORT JCL, SORT JCL INCLUDE EXAMPLE.
TASK 6. FORMATING A FILE (USING INREC)
//SYSIN DD * SORT FIELDS=COPY INREC FIELDS=(7:2,5,20:10,3) /* //* copyright www.mainframegurukul.com
OUTPUT FILE
      OHANK        342a
      OHANK        334
      RAMES        453
      URESH        834
      AMESH        757
      RISHN        083
      RISHN        049
      URESH        834
	
EXPLANATION 1. SORT FIELDS=COPY It is for copy records to output file 2. INREC FIELDS=(7:2,5,20:10,3) (for formatting) Here we have two formattings, 1. 7:2,5 - data at 2nd position of input file with length 5 copied to 7th position of output file 2. 20:10,3 - data at 10th position of input file with length 3 copied to 20th position of output file In above example, we can use OUTREC instread of INREC, INREC adds, deletes, or reformats fields before the records are sorted or merged. so that performance will be improved OUTREC adds, deletes, or reformats fields after the records are sorted or merged.
For more complex INREC and OUTREC SORT JCLs. Refer below discussion at mainframegurukul SORT forums. Hexadecimal to decimal conversion - SORT JCL INREC OUTREC SORT JCL - SORTING A VB FILE - INREC OUTREC PARSE BUILD Sort jcl - report writer queries using OUTREC TAGS : SORT JCL, SORT JCL INRECT, SORT JCL OUTREC
Other parameters we can pass with sort card
SKIPREC=n causes sort to skip over 'n' records in the input file before starting a sorting or copying operation. STOPAFT=n causes sort to stop after 'n' records in the input file have been sorted or copied.
Click here for more details about this jcl book
This book is an excellent book for those who want to become experts in JCL programming
- RAMESH KRISHNA REDDY    


More Details              (Buy at amazon.com)
CURRENT DISCUSSIONS IN -- SORT FORUM www.mainframegurukul.com SPLIT FILE
To compare two files (SSN fields)
DFsort
Omitt records from sort but still include them in output
New DFSORT/ICETOOL Features (April, 2006)
Sumup of the fields in sort
Taking Backup of a Partitioned Dataset using ICEGENER
Selective Copy
WER426I - SYNCSORT ERROR
SORT HELP
z/OS Hot Topics Newsletter
2 input files sorted into 1 output file
Set Return Code using DFSORT
SYNCSORT to Add Fields and Create Summary Records
Reg DFSORT utility.
SYNCSORT - Column Merge
sort and merge
Iebgener or Syncsort
Repeat Report Headers at the top of the page
SYNCSORT - questions
Remove Duplicates and rewrite file unsorted
Query in dfsort / icetool
comparing two flat files
compare two files and write duplicate records to file
Reg:DFSORT
Controlling Return Codes of SORT
A Sort question
DFSORT article in z/Journal (Aug/Sept)
Help required for a sort step of a VB file
File Comparison -Urgent
Sort fields difference
number of records in input file
Outfil outrec
Merging two files into one based on certain key fields:
DFSORT Reporting Issue :Detail Line Customization
sort keeping header as rec1
Summing up of values using Syncsort
compare two files using SORT
DFSORT article in z/Journal (Oct/Nov)
To delete the Trailer REcord from the file
sort two files with same sort condition
Sorting comma delimited file?
how to look up and change
sort with header
search a string
ALternate to IDCAMS-REPRO
ICETOOL /DFSORT Question.
Query on record count in ICETOOL
Sorting twice in same card
Strange result in SORT Arithmatic Division
Copy the fields from more than one DS to one DS
sorting
Regarding date comparision using dfsort urgent
New DFSORT/ICETOOL Features (July, 2008)
Syncsort COBOL E15 exit -error
How to reduce elapse time of a job?
Count of records in the trailer sentence to be changed
Searching a PDS using SORT
Need help in reformatting the records in output file
Copy record when a particular string is present in it
Formatting in PS using DFSORT utility
Doubt in sort
upload download uiotilty question
Checking for empty files
Insert a header record
In this website you can post questions on sort/icetool. Those will get answered by experts in this forum. If any suggestions please send to srcsinc@yahoo.com or click here to send -- A tutorial from DRONA SERIES www.mainframegurukul.com/srcsinc


Visit books section in this site for good books





Search:
Keywords:
In Association with Amazon.com

Home | Donations | Entertainment | Contactme | privacy | privacy