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

SORT altering seq in non sorted columns ?


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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Feb 24, 2011 8:43 pm
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
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
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 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 Remote Unload of CLOB Columns DB2 6
No new posts Increase the number of columns in the... IBM Tools 3
Search our Forums:

Back to Top