IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

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


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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

Global Moderator


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

PostPosted: Wed Jul 20, 2005 6:24 pm
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
Reply with quote

Thanq so much for your quick response
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Oct 01, 2008 3:15 am
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:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 4
No new posts ICETOOL returns no records JCL & VSAM 1
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
Search our Forums:

Back to Top