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
 

 

[Solved]How to copy records from one file to another by jcl

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

New User


Joined: 23 May 2005
Posts: 27

PostPosted: Wed Jul 20, 2005 3:37 pm    Post subject: How to copy records from one file to another by jcl
Reply with quote

Hi
plse clarify my doubt

I want to copy last ten records from the file but I dont know how many records in the file is there any option in the JCL for this plse let me know
ASAP
Back to top
View user's profile Send private message

withnams

New User


Joined: 06 Jul 2005
Posts: 26
Location: Chennai

PostPosted: Wed Jul 20, 2005 4:10 pm    Post subject:
Reply with quote

u can try with 2 steps. first SORT step should create a temp dataset in descending order and the second SORT step should have STOPAFT=10
in the control statement. Thus you will get last 10 records.
Guys let me know if there are any other options.
Back to top
View user's profile Send private message
raghavendraun

New User


Joined: 29 Apr 2005
Posts: 9

PostPosted: Wed Jul 20, 2005 5:58 pm    Post subject: Re: How to copy records from one file to another by jcl
Reply with quote

Hi withnams,

If it is in ascending order then what you told was correct. He has not mentioned about whether input dataset is sorted in ascending order or not.
I think it should be by other means.
Guys please suggest is there any other options ?
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Wed Jul 20, 2005 6:24 pm    Post subject: Re: How to copy records from one file to another by jcl
Reply with quote

This example assumes that the dataset is FB, LRECL=80.
Code:

//COPY     EXEC PGM=ICETOOL     
//IN       DD   DISP=SHR,DSN=input
//T1       DD   DSN=&&T1,DISP=(,PASS),UNIT=VIO             
//OUT      DD   SYSOUT=*                                   
//DFSMSG   DD   SYSOUT=*                                   
//TOOLMSG  DD   SYSOUT=*                                   
//TOOLIN   DD   *                                           
 SORT FROM(IN) USING(CTL1)                                 
 SORT FROM(T1) USING(CTL2)                                 
/*       
//CTL1CNTL DD   *                                           
* ADD SEQUENCE NUMBERS TO RECORDS, THEN SORT BY SEQUENCE   
* NUMBER IN DESCENDING ORDER, SELECTING ONLY THE LAST 10   
* RECORDS.                                                 
  INREC FIELDS=(1,80,81:SEQNUM,8,ZD)                         
  SORT FIELDS=(81,8,ZD,D)                                   
  OUTFIL FNAMES=T1,ENDREC=10                                 
/*                                                         
//CTL2CNTL DD   *                                           
* SORT THE RECORDS BACK INTO THEIR ORIGINAL ORDER, AND     
* REMOVE THE SEQUENCE NUMBERS.                             
  SORT FIELDS=(81,8,ZD,A)                                   
  OUTFIL FNAMES=OUT,OUTREC=(1,80)                           
/*                                                         
//*                                                         
Back to top
View user's profile Send private message
rameshbabu
Warnings : 1

New User


Joined: 23 May 2005
Posts: 27

PostPosted: Thu Jul 21, 2005 11:03 am    Post subject: Re: How to copy records from one file to another by jcl
Reply with quote

Thanq so much for your quick response
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 Oct 01, 2008 3:15 am    Post subject:
Reply with quote

You can now do this kind of thing quite easily using the new SUBSET operator of DFSORT's ICETOOL available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:

Code:

//S1  EXEC  PGM=ICETOOL                                           
//TOOLMSG   DD  SYSOUT=*                                           
//DFSMSG    DD  SYSOUT=*                                           
//IN DD DSN=...  input file                                       
//OUT DD DSN=...  output file         
//TOOLIN DD *                                                     
SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST(10)
/*     


For complete details on the new SUBSET function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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 HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 1 Mon Jan 02, 2017 11:16 am
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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am


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