How can I copy records starting from a certain position in a file to the end of the file?

Document ID : KB000021708
Last Modified Date : 14/02/2018
Show Technical Document Details

Introduction:

To copy records starting from a certain position in a file to the end of the file requires two COPY statements.
The first COPY statement positions you at the starting point in the input file where you want to start the copy from.
The second COPY statement copies all records in the input file to the output file.
After the first COPY statement the STOP(NOCLOSE) keyword is used to keep the input file open and maintain the copy from position in the input file.

Instructions:

In the example below the first COPY statement uses the SELRECIF statement to position to the first record in the input file when the first 10 positions are equal to value C'0001239001'.
Then the STOP(NOCLOSE ) keeps the input file open positioned at the desired record.
The second copy statement copies the remaining records in the input file to the output file.

//COPYREC EXEC PGM=CAWABATC,REGION=2M
//STEPLIB DD DISP=SHR,DSN=FILE.MASTER.CDBILOAD
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//DD01 DD DSN=INPUT.FILE,DISP=SHR
//DD01O DD SYSOUT=A
//SYSIN DD *
COPY,
INFILE(DD01),
OUTFILE(DD01O),
SELRECIF(1,10,EQ,C'0001239001'), <=== Selection criteria value to locate the first record in the input file.
STOP(NOCLOSE) <== STOP(NOCLOSE)
COPY,
INFILE(DD01),
OUTFILE(DD01O)
/*
//