Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to fetch the nth record from a seq file.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
ursvmg

New User


Joined: 24 May 2007
Posts: 52
Location: Chennai

PostPosted: Wed Jun 13, 2007 9:24 am    Post subject: How to fetch the nth record from a seq file.
Reply with quote

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
View user's profile Send private message

Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Wed Jun 13, 2007 10:11 am    Post subject:
Reply with quote

You can do with SORT.
Back to top
View user's profile Send private message
ursvmg

New User


Joined: 24 May 2007
Posts: 52
Location: Chennai

PostPosted: Wed Jun 13, 2007 10:13 am    Post subject:
Reply with quote

I would be thankfull, if the sample piece of code is given
Back to top
View user's profile Send private message
veerababu_p

New User


Joined: 18 Mar 2006
Posts: 5
Location: mumbai

PostPosted: Wed Jun 13, 2007 10:18 am    Post subject:
Reply with quote

Use

Code:

   SORT FIELDS=COPY
   OUTFIL STARTREC=n,ENDREC=n


veera
Back to top
View user's profile Send private message
ursvmg

New User


Joined: 24 May 2007
Posts: 52
Location: Chennai

PostPosted: Wed Jun 13, 2007 11:38 am    Post subject:
Reply with quote

Thanks Veerababu
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Jun 13, 2007 1:58 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Jun 13, 2007 9:02 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Jun 27, 2007 7:10 pm    Post subject:
Reply with quote

Frank,

Thanks for the suggestions, you are a good teacher. icon_smile.gif
Thanks again for providing one rather efficient solution.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us