MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

first and last record of a file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
misi
Beginner


Joined: 14 Apr 2004
Posts: 13
Topics: 10

PostPosted: Thu May 06, 2004 2:57 am    Post subject: first and last record of a file Reply with quote

I have a huge file and I just want the first record in a seperate file and the last record in another file. I dont want to write any programs ,how to do it in jcl

misi
Back to top
View user's profile Send private message
raggop
Beginner


Joined: 05 Feb 2003
Posts: 19
Topics: 3

PostPosted: Thu May 06, 2004 5:05 am    Post subject: Reply with quote

hi,
if you can identify the first and last record of your file you can use dfsort-outfil to pull your first/last record into separate files..

ex
Code:

 //SORTIN DD DSN=E00496.RAG.SORTIN,DISP=SHR
 //G1STATS DD SYSOUT=*                     
 //G2STATS DD SYSOUT=*                     
 //SYSIN DD *                             
  SORT FIELDS=(1,10,CH,A)                 
  OUTFIL FNAMES=G1STATS,                   
     INCLUDE=(1,6,CH,EQ,C'HEADER')         
  OUTFIL FNAMES=G2STATS,                   
     INCLUDE=(1,6,CH,EQ,C'TRAILER')       
 /*                                       
 //SYSPRINT DD SYSOUT=*                   
 //SYSOUT   DD SYSOUT=*                   


hope this helps

raghu
Back to top
View user's profile Send private message
Brian
Beginner


Joined: 12 Aug 2003
Posts: 95
Topics: 6

PostPosted: Thu May 06, 2004 5:06 am    Post subject: Reply with quote

Misi,

You can use this simple fileaid step to get the first and last records into a separate file.

Code:

//STEP0100 EXEC PGM=FILEAID
//SYSPRINT DD SYSOUT=*
//DD01 DD   DSN=INPUT.DATASET,DISP=SHR
//DD02 DD   DSN=INPUT.DATASET,DISP=SHR
//DD01O DD LAST.RECORD.FILE,DISP=...
//DD02O DD FIRST.RECORD.FILE,DISP=...
//SYSIN DD *
$$DD01 COPYBACK OUT=1
$$DD02 COPY OUT=1
/*
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu May 06, 2004 5:42 am    Post subject: Reply with quote

misi,

The following JCL will give you desired results. I assumed that the input file is of recfm FB and is 80 bytes long.

Code:

//STEP0100  EXEC PGM=SORT
//SYSOUT    DD SYSOUT=*   
//SORTIN    DD DSN=YOUR INPUT FILE,
//             DISP=SHR
//FIRST     DD DSN=YOUR FIRST RECORD FILE,
//             DISP=(NEW,CATLG,DELETE),     
//             UNIT=SYSDA,
//             SPACE=(TRK,(1,1),RLSE)
//LAST      DD DSN=YOUR LAST RECORD FILE,
//             DISP=(NEW,CATLG,DELETE),     
//             UNIT=SYSDA,
//             SPACE=(TRK,(1,1),RLSE)
//SYSIN     DD *           
  SORT FIELDS=COPY         
  OUTFIL FNAMES=FIRST,ENDREC=1
  OUTFIL FNAMES=LAST,NODETAIL,REMOVECC,
  TRAILER1=(1,80)
/*


If you get an error on REMOVECC parm then you are using a older version of sort,in that case remove that parm, but the output dataset created will be of FBA format. The first byte will have a carriage control character. you need another pass to remove the carriage control character.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group