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
 

 

SORT altering seq in non sorted columns ?

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

New User


Joined: 31 Aug 2010
Posts: 20
Location: Edinburgh

PostPosted: Thu Feb 24, 2011 7:52 pm    Post subject: SORT altering seq in non sorted columns ?
Reply with quote

I’m not sure why sort is altering the seq of my records, can someone explain the following to me.

I have a two record input file:

Code:
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
****** ***************************** Top of Data ******************************
000001         40300124                                         NA0302RMRS zxcv
       44444444FFFFFFFF44444444444444444444444444444444444444444DCFFFFDDDE4AA8A
       000000004030012400000000000000000000000000000000000000000510302949209735
------------------------------------------------------------------------------
000002         40300124                                         NA0302 MRS zxcv
       44444444FFFFFFFF44444444444444444444444444444444444444444DCFFFF4DDE4AA8A
       000000004030012400000000000000000000000000000000000000000510302049209735
------------------------------------------------------------------------------
****** **************************** Bottom of Data ****************************


I’m sorting with the following sort card

Code:
SORT FIELDS=(01,63,CH,A)


Columns 1 through 63 are identical, however SORT flips the two records around. The only difference in the two records is and ‘R’ as opposed to a blank in col 64.

The output file now has record 1 (record with ‘R’ in pos 64) at the bottom ?
Code:
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
 ****** ***************************** Top of Data ******************************
 000001         40300124                                         NA0302 MRS zxcv
        44444444FFFFFFFF44444444444444444444444444444444444444444DCFFFF4DDE4AA8A
        000000004030012400000000000000000000000000000000000000000510302049209735
 ------------------------------------------------------------------------------
 000002         40300124                                         NA0302RMRS zxcv
        44444444FFFFFFFF44444444444444444444444444444444444444444DCFFFFDDDE4AA8A
        000000004030012400000000000000000000000000000000000000000510302949209735
 ------------------------------------------------------------------------------
 ****** **************************** Bottom of Data ****************************


I’ve even split the two records into two different files and compared them, cols 1 63 are identical. What am I missing ?
Back to top
View user's profile Send private message

Yvonne1980

New User


Joined: 31 Aug 2010
Posts: 20
Location: Edinburgh

PostPosted: Thu Feb 24, 2011 8:36 pm    Post subject:
Reply with quote

Some more puzzling info if anyone is looking at this.

I allocated a FB 80 file with two records, both records have ‘9’s in every column except col 11 which has a ‘R’ in rec 1 and a blank in rec 2:

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
9999999999R999999999999999999999999999999999999999999999999999999999999999999999
9999999999 999999999999999999999999999999999999999999999999999999999999999999999
******************************** Bottom of Data ********************************

I then sort on cols 1 10 with the following sort card

Code:
SORT FIELDS=(01,10,CH,A)


This sort ‘behaves’ as I would expect and gives me the following output:

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
9999999999R999999999999999999999999999999999999999999999999999999999999999999999
9999999999 999999999999999999999999999999999999999999999999999999999999999999999
******************************** Bottom of Data ********************************


When I alter the input file to advance the ‘R’ and blank to col 12 as follows:

Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
99999999999R99999999999999999999999999999999999999999999999999999999999999999999
99999999999 99999999999999999999999999999999999999999999999999999999999999999999
******************************** Bottom of Data ********************************


and run with sort:

Code:
SORT FIELDS=(01,11,CH,A)


It flips the two records and the output looks like:
-
Code:
---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
99999999999 99999999999999999999999999999999999999999999999999999999999999999999
99999999999R99999999999999999999999999999999999999999999999999999999999999999999
******************************** Bottom of Data ********************************


What’s going on ?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10231
Location: italy

PostPosted: Thu Feb 24, 2011 8:43 pm    Post subject: Reply to: SORT altering seq in non sorted columns ?
Reply with quote

from a sort and any logic point of view the final sequence of multiple record with the same <key> is ... irrelevant

sort has the option for multiple occurrences of the same key to write the records in the same order in which they were read
You will incur in some performance penalty, bau if that is Your requirement You will have to bear it

as described here
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA30/3.12?SHELF=ICE1SH31&DT=20080528171007

hint... OPTION EQUALS/NOEQUALS
Back to top
View user's profile Send private message
Yvonne1980

New User


Joined: 31 Aug 2010
Posts: 20
Location: Edinburgh

PostPosted: Thu Feb 24, 2011 9:00 pm    Post subject:
Reply with quote

Thanks Enrico
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 Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm
No new posts JCL sort Match and NoMatch rakeshsekar1987 SYNCSORT 2 Thu Feb 02, 2017 10:26 pm


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