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
 

 

Type of Sorting technique in SORT utility

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

New User


Joined: 24 Feb 2006
Posts: 18
Location: Chennai

PostPosted: Mon Sep 24, 2007 10:58 am    Post subject: Type of Sorting technique in SORT utility
Reply with quote

//MYPGM EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SORTIN DD DSN=FILE1,DISP=SHR
// DD DSN=FILE2,DISP=SHR
//SORTOUT DD DSN=FILE3,DISP=OLD
//SYSIN DD *
SORT FIELDS=(1,3,CH,A)
/*
FILE1
----+----1----+-
100100BISCUT
100501GOOD DAY
100502CRACK JACK

FILE2
----+----1----+-
100100BISCUT
100501TIGER
100502MILKY MAGIC

When I execute the above step i got the output as OPTION A and not as OPTION B. Can anyone explain how it gives OPTION A instead of OPTION B. Also I want to know what kind of sorting technique is used in SORT utility..

OPTION A: FILE3
----+----1----+-
100100BISCUT
100100BISCUT
100501TIGER
100502MILKY MAGIC
100501GOOD DAY
100502CRACK JACK

OPTION B: FILE3
----+----1----+-
100100BISCUT
100501GOOD DAY
100502CRACK JACK
100100BISCUT
100501TIGER
100502MILKY MAGIC
Back to top
View user's profile Send private message

Devzee

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Mon Sep 24, 2007 11:09 am    Post subject:
Reply with quote

Quote:
Can anyone explain how it gives OPTION A

You are copy two files with SORTed columns 1 to 3.

Quote:
OPTION B
To get your desired output,
just do
Code:
 OPTION COPY
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Mon Sep 24, 2007 11:19 am    Post subject: Reply to: Type of Sorting technique in SORT utility
Reply with quote

Quote:
output as OPTION A


If I remember correctly, for equal sorting keys the order of the records is unpredictable !

regards

e.s
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Mon Sep 24, 2007 12:08 pm    Post subject:
Reply with quote

Parthasarathy,

In your example, the first 3 column value are same for all the records. Add few more records with different values (say 101, 102 etc...) and show us how do you want the OP.
Back to top
View user's profile Send private message
ParagChouguley

Active User


Joined: 03 Feb 2007
Posts: 175
Location: PUNE(INDIA)

PostPosted: Mon Sep 24, 2007 12:12 pm    Post subject: Re: Type of Sorting technique in SORT utility
Reply with quote

Parthasarathy wrote:
Can anyone explain how it gives OPTION A instead of OPTION B.


This is because you have concatenated two input files. Here, JCL takes concatenated files as if its one file and then sorts all the records in it. So you are getting single sorted file out of 2 input file.

You may need to change your JCL depending on what you want to do ..

1. Sort 2 input files individually and then concatenate them to prepare a single output file. ??

2. Copy the records from 2 input files to one below another without sorting. ??

--Parag
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Sep 24, 2007 8:13 pm    Post subject:
Reply with quote

Quote:
If I remember correctly, for equal sorting keys the order of the records is unpredictable !


That's true if NOEQUALS is in effect. If EQUALS is in effect, then duplicate records are kept in their original order.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Sep 24, 2007 8:26 pm    Post subject:
Reply with quote

Parthasarathy,

If you want to sort the records and keep duplicate records in their original order, you can use this DFSORT job:

Code:

//MYPGM  EXEC PGM=SORT           
//SYSOUT DD SYSOUT=*   
//SORTIN DD DSN=FILE1,DISP=SHR
// DD DSN=FILE2,DISP=SHR
//SORTOUT DD DSN=FILE3,DISP=OLD
//SYSIN DD *                     
  OPTION EQUALS                 
  SORT FIELDS=(1,3,CH,A)         
/*                               


If you just want to append the records in FILE2 after the records in FILE1 without sorting, then it would be more efficient to use this DFSORT job:

Code:

//MYPGM  EXEC PGM=SORT           
//SYSOUT DD SYSOUT=*   
//SORTIN DD DSN=FILE1,DISP=SHR
// DD DSN=FILE2,DISP=SHR
//SORTOUT DD DSN=FILE3,DISP=OLD
//SYSIN DD *                     
  OPTION COPY                 
/*                               


If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
Back to top
View user's profile Send private message
Parthasarathy

New User


Joined: 24 Feb 2006
Posts: 18
Location: Chennai

PostPosted: Tue Sep 25, 2007 9:14 am    Post subject:
Reply with quote

Thanks Yaeger for giving me the solution.
Thankyou all.
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 TAPE VERIFY utility?? MrExtraordinare JCL & VSAM 3 Fri Dec 09, 2016 10:57 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 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 Efficient sorting chandracdac DFSORT/ICETOOL 5 Sat Oct 22, 2016 3:23 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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