Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 4650
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 Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us