In SORT JCL, the STOPAFT SKIPREC are two conditions that control the processing of input records. You can use the STOPAFT SKIPREC options to reduce the number of records to be processed, which can reduce processor and data transfer time. STOPAFT and SKIPREC are optional parameters and can be used together or separately in a SORT JCL.
If STOPAFT is specified as a PARM option and on the SORT control statement, the PARM specification takes precedence.
//STEP001 EXEC PGM=SORT //$ORTPARM DD * STOPAFT=100 OR //STEP001 EXEC PGM=SORT,PARM='STOPAFT=N' OR //STEP001 EXEC PGM=SORT //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //REPORT1 DD SYSOUT=* //SORTIN DD DISP=SHR,DSN=XXXXXX.YYYYYY.INPFILE, //SORTOUT DD DSN=XXXXXX.YYYYYY.OUTFILE, // DISP=(NEW,CATLG,DELETE), // SPACE=(TRK,(30,10),RLSE), // UNIT=SYSDA, // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS) //SORTWK01 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SORTWK02 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SORTWK03 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SYSIN DD * SORT FIELDS=COPY,STOPAFT=N /* //*
//STEP001 EXEC PGM=ICETOOL //TOOLMSG DD SYSOUT=* //DFSMSG DD SYSOUT=* //IN1 DD DSN=XXXXXX.YYYYY.INPUT,DISP=SHR //OUT1 DD DSN=XXXXXX.YYYYYY.OUTFILE, // DISP=(NEW,CATLG,DELETE), // SPACE=(TRK,(30,10),RLSE), // UNIT=SYSDA, // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS) //TOOLIN DD * COPY FROM(IN1) TO(OUT1) USING(CTL1) /* //CTL1CNTL DD * OPTION STOPAFT=N /*
It’s also worth mentioning that if you’re using the SORT utility with the ICETOOL program, you can use the SELECT operator to achieve similar results to the STOPAFT and SKIPREC conditions. The SELECT operator allows you to specify a range of input records to process or exclude, which can be very helpful in situations where you need to perform complex data manipulations before sorting.
Here’s an example of using the SELECT operator with ICETOOL:
//SORTJOB JOB ... //TOOLSTEP EXEC PGM=ICETOOL //TOOLIN DD * SELECT FROM(IN) TO(OUT) SKIP(10) FIRST(1000) SORT FROM(IN) TO(TEMP) USING(CTL1) OUTFIL FNAMES=OUT,INCLUDE=(1,1,CH,EQ,C'1') /* //CTL1 DD * SORT FIELDS=COPY /*
In this example, the SELECT operator is used to skip the first 10 input records and process only the next 1000 records. The SORT operation is then performed on the selected input data using the CTL1 control statement. Finally, the output data is filtered to include only the records that meet a certain condition using the OUTFIL statement.
//STEP001 EXEC PGM=SORT //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //REPORT1 DD SYSOUT=* //SORTIN DD DISP=SHR,DSN= XXXXXX.YYYYYY.INPFILE, //SORTOUT DD DSN= XXXXXX.YYYYYY.OUTFILE, // DISP=(NEW,CATLG,DELETE), // SPACE=(TRK,(30,10),RLSE), // UNIT=SYSDA, // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS) //SORTWK01 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SORTWK02 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SORTWK03 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SYSIN DD * SORT FIELDS=COPY,SKIPREC=N /* //*
//STEP001 EXEC PGM=SORT //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //REPORT1 DD SYSOUT=* //SORTIN DD DISP=SHR,DSN= XXXXXX.YYYYYY.INPFILE, //SORTOUT DD DSN= XXXXXX.YYYYYY.OUTFILE, // DISP=(NEW,CATLG,DELETE), // SPACE=(TRK,(30,10),RLSE), // UNIT=SYSDA, // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS) //SORTWK01 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SORTWK02 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SORTWK03 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SYSIN DD * SORT FIELDS=COPY,SKIPREC=X,STOPAFT=Y /* //*
Example: Sort the input file on the basis of the first 11 bytes then format the output file for the first 10000 records.
//SYSUDUMP DD SYSOUT=* //REPORT1 DD SYSOUT=* //SORTIN DD DISP=SHR,DSN= XXXXXX.YYYYYY.INPFILE, //SORTOUT DD DSN= XXXXXX.YYYYYY.OUTFILE, // DISP=(NEW,CATLG,DELETE), // SPACE=(TRK,(30,10),RLSE), // UNIT=SYSDA, // DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS) //SORTWK01 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SORTWK02 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SORTWK03 DD UNIT=DISK,SPACE=(CYL,(20,5),RLSE) //SYSIN DD * SORT FIELDS=(01,11,BI,A),SKIPREC=1,STOPAFT=10000 OUTREC FIELDS=(001:001,35, 036:036,05,PD,EDIT=(TTTTTTTTT), 045:041,02,PD,EDIT=(TTT), 048:043,05, 053:048,03,PD,EDIT=(TTTTT), 058:051,03,PD,EDIT=(TTTTT), 063:054,08,PD,EDIT=(TTTTTTTTTTTTTTT)) /* //*
SKIPREC and STOPAFT parameters can be used in conjunction with other parameters in the SORT control statement to create more complex sorting operations. For example, you might use the INCLUDE or OMIT parameters to filter out certain records before sorting or the SUM parameter to create summary information about the input data.
Here’s an example SORT control statement that uses the SKIPREC and SUM parameters to sort a file while skipping the first 10 records and creating a summary report:
SORT FIELDS=(1,10,CH,A) SKIPREC=10 SUM FIELDS=(11,4,ZD)
In this example, the SORT utility will sort the input file based on the first 10 characters of each record, while skipping the first 10 records. The SUM parameter will also be used to create a summary report based on the 4-byte numeric field starting at position 11 in each record.
SKIPREC and STOPAFT parameters can be used with both fixed-format and variable-length records. When working with variable-length records, you’ll need to specify the record length using the RECL parameter in the SORT control statement.
Here’s an example SORT control statement that sorts a variable-length input file while skipping the first 5 records and limiting the sorting to the first 1000 bytes of each record:
SORT FIELDS=(1,10,CH,A) SKIPREC=5 INREC IFTHEN=(WHEN=INIT,OVERLAY=(1001:SEQNUM,8,ZD)), IFTHEN=(WHEN=(1001,8,ZD,LE,1000),BUILD=(1,1000)) OUTREC BUILD=(1,1000) RECL=1000
In this example, the SORT utility will sort the input file based on the first 10 characters of each record, while skipping the first 5 records. The INREC statement is used to add a sequence number to each record and limit the sorting to the first 1000 bytes of each record. The OUTREC statement is used to remove the sequence number from the output records. The RECL parameter is set to 1000 to specify the maximum record length for variable-length records.
In summary, the STOPAFT and SKIPREC conditions are very useful in limiting the amount of data that needs to be sorted and can help reduce processing time and save on system resources. By using these conditions, you can process only the subset of data that is needed for a particular task, rather than sorting the entire input file.
If you need to perform more complex data manipulations before sorting, you may want to consider using the ICETOOL program with the SELECT operator or other operators that can help you achieve the desired results.
Furthermore, by using the SKIPREC and STOPAFT parameters in conjunction with other SORT control statement parameters, you can create complex sorting operations that meet your specific needs, whether you’re working with fixed-format or variable-length records.
Overall, understanding how to use the SKIPREC and STOPAFT parameters in the SORT utility is an important skill for anyone working with mainframe systems and can help you optimize your sorting operations and improve performance.
Effective Product Owner plays a crucial role in Agile development, acting as the bridge between…
A well-maintained product backlog is crucial for successful product development. It serves as a single…
Incremental value to the customer refers to the gradual delivery of small, functional parts of…
A Product Market refers to the group of potential customers who might be interested in…
The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…
The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…