Page 1 of 1

Verify if a sequentila file is sorted or not?

Posted: Mon Oct 13, 2014 5:01 pm
by Girish Kannad
Hi,

I have this doubt from so many days: I have a sequentila file with say millions of records. Now, how can I verify whether it is sorted or not? One way I can think of that manually I can check the dataset but how many records will I check for the order so is there any other way out?

Any help in this regard is appreciated.

Re: Verify if a sequentila file is sorted or not?

Posted: Mon Oct 13, 2014 8:12 pm
by William Collins
Best thing to do is wherever the file is read, check the order at the time. Then you won't have to do it separately (save resources = money) and you'll be confident that the file is in order.

Re: Verify if a sequentila file is sorted or not?

Posted: Tue Oct 14, 2014 6:10 am
by Robert Sample
If you have a sequential data set with millions of records, how do you NOT know if the data set is sorted? Most applications sort data as needed, and a data set will not unsort itself.

Re: Verify if a sequentila file is sorted or not?

Posted: Tue Oct 14, 2014 8:36 am
by Anuj Dhawan
Another way to determine if a file is sorted or not, you can do a one-file merge with SORT as follows. I used a BI sort key in positions 1-11 for the example.

Code: Select all

//STEP1 EXEC PGM=ICEMAN 
//SYSOUT DD SYSOUT=* 
//SORTIN01 DD DSN=...  input file 
//SORTOUT DD DUMMY 
//SYSIN DD * 
  MERGE FIELDS=(1,11,BI,A) 
/* 
If the file is already sorted, you'll get return code 0. If the file is not already sorted, you'll get an error message and return code 16.