stop after in sort jcl - SORT JCL tutorials

What is STOPAFT in sort jcl

SORT utility is useful to copy records from one file to other file. There are so many other advantages with SORT utility. This part of the tutorial will cover the STOPAFT in sort.

Consider the following requirement.

you have given a file which contains 1000 records and you have asked to write the first 100 records to another file. how can you achieve this ..?

SORT utility has the option STOPAFT which will help us to achieve the above requirement. Let us start with learning the syntax.

Syntax of STOPAFT

//SYSIN DD *

SORT FIELDS=COPY,STOPAFT=number_records

/*

In the above syntax SORT FIELDS=COPY tells that copy the records from the specified input file to the specified output file. And the SORT option STOPAFT = number_records tells that stop copying the records after the specified number of records are copied.

Example of STOPAFT

The following is the example which shows how to use the STOPAFT to stop copying the records after copying the 100 records.

//STOPAFT JOB (ACCINFO),userid,CLASS=S,MSGCLASS=0
//*
//PS010 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//********************************************************************
//* INPUT FILE FOR SORTING *
//********************************************************************
//SORTIN DD DSN=TEST.INPUT.FILE.RECDS,DISP=SHR
//********************************************************************
//* OUTPUT FILE FOR SORTING *
//********************************************************************
//SORTOUT DD DSN=TEST.OUTPUT.FILE.RECDS,
// DISP=(OLD,CATLG,DELETE),UNIT=WORK,
// SPACE=(TRK,(100,50),RLSE),DCB=*.SORTIN
//****************************************************
//* STOP AFTER WRITING 100 RECORDS *
//****************************************************
//SYSIN DD *
SORT FIELDS=COPY,
STOPAFT=100 --> STOPS after copying 100 records
/*
//

In the above eample 100 records from the input file TEST.INPUT.FILE.RECDS will be copied into output file TEST.OUTPUT.FILE.RECDS

More by this Author


Comments

No comments yet.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working