View previous topic :: View next topic
|
Author |
Message |
ursvmg
New User
Joined: 24 May 2007 Posts: 52 Location: Chennai
|
|
|
|
I have a sequential file. I want to take out the nth record from that file. Please tell me how it is possible.
Thanks,
Gopal |
|
Back to top |
|
|
Devzee
Active Member
Joined: 20 Jan 2007 Posts: 684 Location: Hollywood
|
|
|
|
You can do with SORT. |
|
Back to top |
|
|
ursvmg
New User
Joined: 24 May 2007 Posts: 52 Location: Chennai
|
|
|
|
I would be thankfull, if the sample piece of code is given |
|
Back to top |
|
|
veerababu_p
New User
Joined: 18 Mar 2006 Posts: 5 Location: mumbai
|
|
|
|
Use
Code: |
SORT FIELDS=COPY
OUTFIL STARTREC=n,ENDREC=n
|
veera |
|
Back to top |
|
|
ursvmg
New User
Joined: 24 May 2007 Posts: 52 Location: Chennai
|
|
|
|
Thanks Veerababu |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Gopal,
Try using the below JCL.
Code: |
//JOBCARD
//SORTIN DD DSN=HLQ.FIRST.FILE,
// DISP=SHR
//SORTOUT DD DSN=HLQ.FIRST.FILE.OUT,
// DISP=(NEW,CATLG,CATLG),
// DSORG=PS,
// RECFM=FB,
// DATACLAS=LARGE,
// UNIT=SYSDA
//SORTWK01 DD UNIT=SYSDA,SPACE=(CYL,(20,5))
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=SORTOUT,STARTREC=3,ENDREC=3
/*
//SORTMSG DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//CEEDUMP DD SYSOUT=*
//* |
where HLQ.FIRST.FILE is
Code: |
111 $$$$$
222 AAAAA
444 FFFFF
555 GGGGG
888 CCCCC |
& I want only 3rd record of input (444 FFFFF) in the output. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Anuj,
1) Since you're doing a COPY you shouldn't use a //SORTWKnn DD.
2) You don't need //SORTMSG, //SYSPRINT or //CEEDUMP.
3) You don't need FNAMES=SORTOUT since that's the default.
4) You don't need to specify RECFM=FB or DSORG=PS for SORTOUT since DFSORT will automatically set the attributes.
So a better version of your job would be:
Code: |
//JOBCARD
//SORTIN DD DSN=HLQ.FIRST.FILE,
// DISP=SHR
//SORTOUT DD DSN=HLQ.FIRST.FILE.OUT,
// DISP=(NEW,CATLG,CATLG),
// DATACLAS=LARGE,
// UNIT=SYSDA
//SYSIN DD *
OPTION COPY
OUTFIL STARTREC=3,ENDREC=3
/*
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//*
|
However, if would be more efficient to use:
Code: |
//SYSIN DD *
OPTION COPY,SKIPREC=2,STOPAFT=1
/*
|
which reads and skips the first two records, reads and writes the third record and stops without reading the rest of the records, whereas STARTREC=3,ENDREC=3 reads every record but only copies the third record. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Frank,
Thanks for the suggestions, you are a good teacher.
Thanks again for providing one rather efficient solution. |
|
Back to top |
|
|
|