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
 

 

to copy last 50 records of a flat file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
krishnareddymsc

New User


Joined: 08 Jan 2007
Posts: 9
Location: Bangalore

PostPosted: Thu Jan 11, 2007 3:56 pm    Post subject: to copy last 50 records of a flat file
Reply with quote

How can we copy last 50 records from a flat file to another file....as we dont know tha max number of records in that file.....and also pls explain for the same with ksds files........thanku...............
Back to top
View user's profile Send private message

Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1105
Location: The Netherlands at Hole 19

PostPosted: Thu Jan 11, 2007 3:59 pm    Post subject:
Reply with quote

Repro with IDCAMS to dummy-file and you know the number of records. Then repro with SKIP total number minus 50. Also check the sortforum where Frank offers a lot of solutions.
Back to top
View user's profile Send private message
superk

Moderator Team Head


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

PostPosted: Thu Jan 11, 2007 7:31 pm    Post subject: Re: to copy last 50 records of a flat file
Reply with quote

You sort the dataset, adding a sequential counter to the end of each record.

Then, you sort the data on the sequential counter in descending order, stopping after 50 records.

Finally, resort the data on the sequential counter in ascending order, and remove the count value from 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: Thu Jan 11, 2007 10:41 pm    Post subject:
Reply with quote

You can use the technique shown in the "Keep the last n records" Smart DFSORT Trick at:

http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
Back to top
View user's profile Send private message
krishnareddymsc

New User


Joined: 08 Jan 2007
Posts: 9
Location: Bangalore

PostPosted: Fri Jan 12, 2007 2:16 pm    Post subject: reg: copy 50 records ina anew file
Reply with quote

Hi all,
thanx for your nice reply..........I think I gt my answer.....with your views....sone more thing...can you explain the same...with VSAm Ksds files......?
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jan 14, 2007 12:27 pm    Post subject:
Reply with quote

You can use this for flat files too.
Code:

//COPYKEY EXEC PGM=FILEAID
//DD01     DD  DSN=YOUR.VSAM.FILE
//DD01O    DD  DSN=file.contains.50highest.key.recs
//SYSIN    DD  *
$$DD01 COPYBACK OUT=50
/*
//*
//NEXT    EXEC PGM=....
//HIGHKEY DD DSN=file.contains.50highest.key.recs,
//etc....
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm


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