SORT altering seq in non sorted columns ?

Author Message
Yvonne1980

New User

Joined: 31 Aug 2010
Posts: 20
Location: Edinburgh

Posted: Thu Feb 24, 2011 7:52 pm

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 ?
Yvonne1980

New User

Joined: 31 Aug 2010
Posts: 20
Location: Edinburgh

Posted: Thu Feb 24, 2011 8:36 pm

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 ?
enrico-sorichetti

Senior Moderator

Joined: 14 Mar 2007
Posts: 10712
Location: italy

 Posted: Thu Feb 24, 2011 8:43 pm from a sort and any logic point of view the final sequence of multiple record with the same 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
Yvonne1980

New User

Joined: 31 Aug 2010
Posts: 20
Location: Edinburgh

 Posted: Thu Feb 24, 2011 9:00 pm Thanks Enrico
 View Bookmarks All times are GMT + 6 Hours

 Topic Forum Replies Similar Topics Date conversion using SORT SYNCSORT 4 Which SORT utility can improve the Pe... DFSORT/ICETOOL 16 Using sort on VB records based on off... DFSORT/ICETOOL 6 COBOL VS SORT Utility for file format... COBOL Programming 6 Copying data from prev record using SORT SYNCSORT 19
Search our Forums:

 © 2003-2021  IBM MAINFRAMES Software & Support Division Board Rules | FAQ | Downloads | Wiki | SiteMap | Contact Us