Page 1 of 1

SORT Statement

PostPosted: Tue Nov 03, 2009 3:35 pm
by Vineet
Hi All,

I am having Query Regarding SORT Statement. I am having a Sequential File (Dynamic in nature) i.e. Record Count Vary on daily Basis, say On 3rd/Nov/2009 Record Count = 5000, 4/Nov/2009 Record Count = 10000, 5/Nov/2009 Record Count = 50
I want to get Last 500 Records How To Achieve this?. For 5/Nov/2009 will I be Getting Error or On 50 Records will be Fetched.

Thanks
Kind Rgds

Vineet Anand

Re: SORT Statement

PostPosted: Tue Nov 03, 2009 5:09 pm
by Vineet
Let be More e Precise with the requirement. I want to Write last 500 Records to a Output File.

Re: SORT Statement

PostPosted: Tue Nov 03, 2009 10:24 pm
by Frank Yaeger
I want to Write last 500 Records to a Output File.


You can use a DFSORT/ICETOOL job like the following to do that:

//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(500)
/*


If you have 500 or more records in IN, you will get the last 500 records. If you have less than 500 records in IN, you will get all of the records.

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss? ... g3T7000080