Sunday, December 28, 2008

DATASORT (Sort recs between header and trailer)

DATASORT is a new ICETOOL operator that allows you to sort the data records in a data set without sorting the header or trailer records. DATASORT gives you new capabilities for sorting the data records between header records (first n records of the data set) and trailer records (last n records of the data set) while keeping the header and trailer records in place.

EX : Your file has 100 records and you want to sort the file from 3rd record to 99th record only.

//TOOLIN DD *
DATASORT FROM(IN) TO(OUT) HEADER(2) TRAILER USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(1,4,CH,A)

I/P :
Header 001
Header 002
BBBB
CCCC
AAAA
DDDD
Trailer 001

O/P :
Header 001
Header 002
AAAA
BBBB
CCCC
DDDD
Trailer 001

Hope you find it useful. Its pretty easy as it doesn't requires any identifiers for header and trailer records. Just mention header and trailer record numbers.

Please do provide your comments or reactions. For further reference click here.

No comments:

Post a Comment