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

Copy file and check if sorted


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

Active User


Joined: 29 Oct 2010
Posts: 202
Location: Toronto, ON, Canada

PostPosted: Tue Oct 15, 2013 10:45 pm
Reply with quote

I had a situation where I wanted to run a sort copy operation on a file that should already be sorted. I wanted a way to check that the file was indeed sorted and give a non-zero return code if not.

Option 1
Sort the file anyway. This would use a lot of resources if the file was large. Not sure if DFSORT can detect that a file is already sorted and minimize the resource usage.

Option 2
Do a SORTKEYS join to an empty file using the "SORTED" keyword. File F1 would be the input and file F2 would just be empty.
Code:
JOINKEYS FILE=F1,FIELDS=(something),SORTED
JOINKEYS FILE=F2,FIELDS=(something)
SORT FIELDS=COPY

This will fail if the input file is not sorted.

Option 3
I wrote a COBOL exit program that will check each record to the previous one and force a terminate (RC=16) if not sorted. It works but this is limited. It has to read a dd on the first call to get the field position and length.

Option 4
This doesn't exist but it would be nice if IBM added a feature to DFSORT to check that a file is already sorted. Suggested syntax:
Code:
SORT CHECK=(something)

DFSORT would then flag any record that is not in sorted order and terminate with a non-zero return code.

Thoughts? Suggestions? Ideas?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Tue Oct 15, 2013 11:32 pm
Reply with quote

Identify if a file (sic) is already sorted.
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 202
Location: Toronto, ON, Canada

PostPosted: Wed Oct 16, 2013 2:52 am
Reply with quote

Thanks for the info. I had not thought to try a MERGE.

This works but is a "trick" as technically I am not doing a merge. By definition a merge requires 2 or more things.

The functionality already exists within DFSORT to check sort order. It would make sense to have an actual syntax command for this.
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: Wed Oct 16, 2013 4:37 am
Reply with quote

You can MERGE with one input. It will check the keys. It will fail if out-of-sequence.

Why don't you know if the file is sorted?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Oct 16, 2013 6:11 pm
Reply with quote

Hello,

If the sequence of the file is in question, the file needs to be sorted.

If the file is already in sequence the sort will run exponentially faster than if the data is out of sequence.
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 3
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