View previous topic :: View next topic
|
Author |
Message |
krishnareddymsc
New User
Joined: 08 Jan 2007 Posts: 9 Location: Bangalore
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
Back to top |
|
|
krishnareddymsc
New User
Joined: 08 Jan 2007 Posts: 9 Location: Bangalore
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
|