balasarathi Beginner
Joined: 24 Aug 2006 Posts: 4 Topics: 2
|
Posted: Thu Sep 28, 2006 12:09 am Post subject: File Aid Copy |
|
|
Hi All,
I have a requirement to copy few records into an output file.
The selection criteria for the same is,
I/P file contails 1000's of records. The requirement is to copy the first record(header) and the last record(Trailer) and have to copy every 1000'th record.
i.e.
Header
1000'th record
2000'th record
3000'th record
4000'th record
5000'th record
..
..
..
..
..
Trailer
Can some one Help me how to copy the records in both sort and file-aid.
Regards,
Sarathi. |
|
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Sep 28, 2006 8:07 am Post subject: |
|
|
balasarathi,
Try this
Code: |
//STEP0100 EXEC PGM=FILEAID
//SYSPRINT DD SYSOUT=*
//DD01 DD DSN=YOUR INPUT FILE,
// DISP=SHR
//DD01O DD DSN=YOUR OUTPUT FILE,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
$$DD01 COPY IF=(1,EQ,C'HEADER'),OUT=1
$$DD01 COPY SELECT=1000,IF=(1,NE,C'TRAILER'),OUT=0
$$DD01 COPYBACK OUT=1
|
Sort Solution: I assumed that your input file has 80 bytes lrecl and is of FB recfm.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=YOUR INPUT FILE,
// DISP=SHR
//SORTOUT DD DSN=YOUR OUTPUT FILE,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(X,Y),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:SEQNUM,3,ZD,START=0,INCR=1)),
IFTHEN=(WHEN=(1,6,CH,EQ,C'HEADER'),
OVERLAY=(81:C'000')),
IFTHEN=(WHEN=(1,7,CH,EQ,C'TRAILER'),
OVERLAY=(81:C'000'))
OUTFIL INCLUDE=(81,3,ZD,EQ,0),
OUTREC=(1,80)
/*
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|