IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Identify if a File is already Sorted.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Vinodh S

New User


Joined: 12 Apr 2012
Posts: 28
Location: LA, California

PostPosted: Fri Feb 01, 2013 8:00 am
Reply with quote

Hi

I have a tape file and its huge. Is there a way in SORT to identify if a file is sorted.

Say I want to check if the file is sorted by the position 1 to 10.
Back to top
View user's profile Send private message
Vinodh S

New User


Joined: 12 Apr 2012
Posts: 28
Location: LA, California

PostPosted: Fri Feb 01, 2013 8:51 am
Reply with quote

In the JOINKEYS statement when the file is already sorted, we would give the SORTED Keyword if the file is already sorted. And if the records are not in the sorted order, it Would terminate.

I'm just looking for something like this. Is there any function in SORT that would say whether the file is already SORTED or not.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Feb 01, 2013 12:01 pm
Reply with quote

since to determine if the file is sorted You might have to read all the records
there is no advantage in doing it.

just write Jour Joinkeys step assuming that the file is not sorted.

anyway the way to do it is to write a fake MERGE
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Feb 01, 2013 1:17 pm
Reply with quote

Ask the owner of the dataset, he/she should know if the file is sorted at creation or in some other job where it is used. Using dataset naming conventions (like jobname, ddname etc. in the dsn). And for the rest what Enrico says.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Feb 01, 2013 1:25 pm
Reply with quote

Quote:
In the JOINKEYS statement when the file is already sorted, we would give the SORTED Keyword if the file is already sorted. And if the records are not in the sorted order, it Would terminate.


hit enter too early ...

do You need the joinkey result or not ...
if You need it just assume the worst
if You do not.. why waste resources checking

or ... fix the whole process to start with
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Feb 01, 2013 2:14 pm
Reply with quote

Add a sequence number say if lrecl is 80 add a sequnce number at 81 and Do a sort on 1,10
Add a sequence number at 91 and check if value from 81-90 = 91-100

If they are not equal the for all records or any first hit then the file is not sorted initially
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Feb 01, 2013 2:18 pm
Reply with quote

Pandora don' t You think that Your suggestion is a bit too complicated ? icon_wink.gif
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Feb 01, 2013 2:24 pm
Reply with quote

I guess it is considering the tape it is even more icon_redface.gif

But what TS could also do is if he s not sure about the data in Tape he could just sort it before processing
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Feb 01, 2013 2:25 pm
Reply with quote

Whenever I read a file in "key order" I check that it is in "key order": along with the rest of the program, there is little overhead in this compared to the knowledge that the file is OK.

To do this "standalone", as enrico suggested:

Code:
  MERGE FIELDS=(key-to-be-verified)


//DD SORTIN01 DD your datatest
//DD SORTOUT DD DUMMY or NULLFILE



The step will fail if not in sequence.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Feb 01, 2013 2:28 pm
Reply with quote

IMO, this kind of questions are just a waste of everybody' s time
see my previous questions and comments

once a process has passed all the acceptance tests no need to check for anything
everybody is allowed to assume that the process works as <certified> ,
if at some point it does not ... time to kick some ass icon_wink.gif
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Feb 01, 2013 2:31 pm
Reply with quote

Thanks Bill and Enrico
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Feb 01, 2013 2:38 pm
Reply with quote

and to stick deeper the knife into the wound ...

these "trucs et astuces" should be part of the tools chest of any testing team
( have been for ages in any reasonably organized shop )

checking if a file is properly ordered is part of the basics test usually present in most of the checklists
Back to top
View user's profile Send private message
Vinodh S

New User


Joined: 12 Apr 2012
Posts: 28
Location: LA, California

PostPosted: Sat Feb 02, 2013 12:06 am
Reply with quote

Bill Woodger wrote:
Whenever I read a file in "key order" I check that it is in "key order": along with the rest of the program, there is little overhead in this compared to the knowledge that the file is OK.

To do this "standalone", as enrico suggested:

Code:
  MERGE FIELDS=(key-to-be-verified)


//DD SORTIN01 DD your datatest
//DD SORTOUT DD DUMMY or NULLFILE



The step will fail if not in sequence.


Thanks Bill. I'll use this to test if my file is already sorted.

The reason I posted this ques is, I have a step in a job where multiple files are concatenated in the SORTIN DD and written out to a VSAM file. The step uses the SORT FIELDS=(1,10,CH,A).

I was thinking if the Files were are already sorted, I could use the Merge command instead of the SORT Command so that the performance of the step would increase. So in order to test if the files are already sorted by the required field I couldn't think of a direct method to do so.

PS: Yes I can always look at the Jobs where the files are getting created and check how the file would be Sorted. But there are many files to reach out. Anyway after checking the files with the idea BILL has mentioned, I Would look onto how the files are created.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Sat Feb 02, 2013 12:20 am
Reply with quote

If in fact all the data sets are concatenated under SORTIN, then for this purpose they can be considered a single data set; not only must each data set itself be sorted, but the last key in the nth data set must be no higher than the first key in the n+1th.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Feb 02, 2013 1:59 am
Reply with quote

True for SORT, but for MERGE each has its own DD. A MERGE of a lot of data is going to consume fewer resources than a SORT of the same data. Worth spending the time to check, and even arranging for them all to be in order, if some already are.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Feb 02, 2013 2:08 am
Reply with quote

Quote:
I was thinking if the Files were are already sorted, I could use the Merge command instead of the SORT Command so that the performance of the step would increase. So in order to test if the files are already sorted by the required field I couldn't think of a direct method to do so.


did You read my previous comments about the correctness of the process

look at the process documentation/specifications and if it tells that each datasets is in the proper sequence just use a merge


there is a bit of miscommunication around here or You are looping around

icon_wink.gif
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Sat Feb 02, 2013 5:04 am
Reply with quote

How huge is this tape file? - i.e. number of records, lrecl, blksize?

If this truly is huge, copy the first x-amount of records and see if they are in sorted order. Not full-proof of course but quick and relatively reliable.

Why make this so complicated?
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Sat Feb 02, 2013 6:26 am
Reply with quote

...or copy every n-th record for x-amount and see if in sorted order.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top