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

Type of Sorting technique in SORT utility


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Mon Sep 24, 2007 11:19 am
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: 1436
Location: Bangalore,India

PostPosted: Mon Sep 24, 2007 12:08 pm
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
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 Developer


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

PostPosted: Mon Sep 24, 2007 8:13 pm
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 Developer


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

PostPosted: Mon Sep 24, 2007 8:26 pm
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:

Use [URL] BBCode for External Links
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts REASON 00D70014 in load utility DB2 6
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top