Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Identify if a File is already Sorted.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Vinodh S

New User


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

PostPosted: Fri Feb 01, 2013 8:00 am    Post subject: Identify if a File is already Sorted.
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: 30
Location: LA, California

PostPosted: Fri Feb 01, 2013 8:51 am    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Fri Feb 01, 2013 12:01 pm    Post subject: Reply to: Identify if a File is already Sorted.
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: 2422
Location: Netherlands, Amstelveen

PostPosted: Fri Feb 01, 2013 1:17 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Fri Feb 01, 2013 1:25 pm    Post subject: Reply to: Identify if a File is already Sorted.
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

Moderator


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

PostPosted: Fri Feb 01, 2013 2:14 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Fri Feb 01, 2013 2:18 pm    Post subject: Reply to: Identify if a File is already Sorted.
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

Moderator


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

PostPosted: Fri Feb 01, 2013 2:24 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri Feb 01, 2013 2:25 pm    Post subject: Reply to: Identify if a File is already Sorted.
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Fri Feb 01, 2013 2:28 pm    Post subject: Reply to: Identify if a File is already Sorted.
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

Moderator


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

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

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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Fri Feb 01, 2013 2:38 pm    Post subject: Reply to: Identify if a File is already Sorted.
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: 30
Location: LA, California

PostPosted: Sat Feb 02, 2013 12:06 am    Post subject: Re: Reply to: Identify if a File is already Sorted.
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: 1738
Location: Bloomington, IL

PostPosted: Sat Feb 02, 2013 12:20 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sat Feb 02, 2013 1:59 am    Post subject: Reply to: Identify if a File is already Sorted.
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Sat Feb 02, 2013 2:08 am    Post subject: Reply to: Identify if a File is already Sorted.
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us