Copy a number of records depending on the number and type
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Utilities

#1: Copy a number of records depending on the number and type Author: nandwana.kanishk886 PostPosted: Fri Jun 23, 2017 7:23 am
    —
Hi All,
Please spare me for making any mistake in my question.
I have to copy first thousand record from one file to another file depending on a condition
Record length for the file is 80,
File structure is as follows
Code:

12345 ABCDED GHIJKLMNOPQR111111111111111
12345 ABCDED GHIJKLMNOPQR222222222222222
12345 ABCDED GHIJKLMNOPQR333333333333333
22222 ABCDED GHIJKLMNOPQR444444444444444
22222 ABCDED GHIJKLMNOPQR555555555555555
22222 ABCDED GHIJKLMNOPQR666666666666666

for example my 1000th record is
Code:

22222 ABCDED GHIJKLMNOPQR555555555555555

then I need to copy till 12345 ABCDED GHIJKLMNOPQR333333333333333

Basically If I cannot all the records for the (1,5). I need to copy till the last key.
I want to do this by a jcl.

#2:  Author: kolusuLocation: San Jose PostPosted: Fri Jun 23, 2017 10:25 am
    —
nandwana.kanishk886,

It is not clear as to what you want. Do you want to copy ALL the records till you find the key '22222' or do you want copy the first 999 records as 1000th record is '2222' ?

I am guessing that it is the first case and here is a JCL which will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                       
12345 ABCDED GHIJKLMNOPQR111111111111111               
12345 ABCDED GHIJKLMNOPQR222222222222222               
12345 ABCDED GHIJKLMNOPQR333333333333333               
22222 ABCDED GHIJKLMNOPQR444444444444444               
22222 ABCDED GHIJKLMNOPQR555555555555555               
22222 ABCDED GHIJKLMNOPQR666666666666666               
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                       
  OPTION COPY                                         
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'22222'),
                PUSH=(81:ID=1))               
         
  OUTFIL BUILD=(1,80),INCLUDE=(81,1,CH,EQ,C' ')       
//*


The output from this job is

Code:

12345 ABCDED GHIJKLMNOPQR111111111111111
12345 ABCDED GHIJKLMNOPQR222222222222222
12345 ABCDED GHIJKLMNOPQR333333333333333



MVSFORUMS.com -> Utilities


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group