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.
Verify if a sequentila file is sorted or not?
-
- New Member
- Posts: 3
- Joined: Thu Jul 31, 2014 2:57 pm
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Verify if a sequentila file is sorted or not?
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.
- Robert Sample
- Global Moderator
- Posts: 1895
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Verify if a sequentila file is sorted or not?
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.
- Anuj Dhawan
- Founder
- Posts: 2802
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Verify if a sequentila file is sorted or not?
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.
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.
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)
/*
Thanks,
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute