IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

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

Senior Member


Joined: 14 Mar 2007
Posts: 10696
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
Use [URL] BBCode for Links

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 All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts COBOL VS SORT Utility for file format... COBOL Programming 6
No new posts Copying data from prev record using SORT SYNCSORT 19
No new posts Combining more 4 files with sorted or... DFSORT/ICETOOL 3
No new posts Altering output file attributes All Other Mainframe Topics 5
This topic is locked: you cannot edit posts or make replies. Parsing more than 1000 columns in a s... SYNCSORT 10

Back to Top