SKIPREC in SORT - SORT JCL Tutorials

What is SKIPREC in SORT JCL

SKIPREC is used to skip the initial number of specified records from copying. SKIPREC option is used with SORT utility.

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 SKIPREC in sort.

Consider the following requirement.

Your manager or team lead has given you a file and asked you to skip the initial 1000 records from the file and write the remaining all records to the other file. How can you do this using JCL?

Here is the solution

SKIPREC option in SORT will help us to achieve the above requirement. The following is the syntax of SKIPREC.

Syntax of SKIPREC

//SYSIN DD *

SORT FIELDS=COPY,SKIPREC=number_records

/*

In the above syntax SORT FIELDS=COPY copies the records from the specified input file to the specified output file. And the SORT option SKIPREC = number_records tells that skip the initial number_ records then start the copy process from number_records + 1th record.

Example of SKIPREC

The following example explains how we can do the above requirement of skipping the initial 1000 records from copying using the SORT utility option SKIPREC

Example´╗┐:

//SKIPREC JOB (ACCINFO),user_id,CLASS=D,MSGCLASS=0,REGION=OM
//**********************************************************
//STEP001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//**********************************************************
//* INPUT FILE FOR SORTING *
//***********************************************************************************
//SORTIN DD DSN=ADMIN.DEMO.INPUT.FILE1.RECDS,DISP=SHR
//***********************************************************************************
//* OUTPUT FILE FOR SORTING *
//***********************************************************************************
//SORTOUT DD DSN= ADMIN.DEMO.OUTPUT.FILE1.RECDS,
// DISP=(NEW,CATLG,DELETE),UNIT=WORK,
// SPACE=(TRK,(100,50),RLSE),DCB=*.SORTIN
//***********************************************************************************
//* STOP AFTER WRITING 100 RECORDS *
//***********************************************************************************
//SYSIN DD *
SORT FIELDS=COPY,
SKIPREC=1000 --> SKIPS the initial 1000 records.

/*
//

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