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
 

 

Copy file and check if sorted

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

Active User


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

PostPosted: Tue Oct 15, 2013 10:45 pm    Post subject: Copy file and check if sorted
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: 1746
Location: Bloomington, IL

PostPosted: Tue Oct 15, 2013 11:32 pm    Post subject:
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: 183
Location: Toronto, ON, Canada

PostPosted: Wed Oct 16, 2013 2:52 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7255

PostPosted: Wed Oct 16, 2013 4:37 am    Post subject: Reply to: Copy file and check if sorted
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

Site Director


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

PostPosted: Wed Oct 16, 2013 6:11 pm    Post subject:
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    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 SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 1 Mon Jan 02, 2017 11:16 am
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
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


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