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

Sorted Data not in sequence


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Mon Apr 02, 2012 4:07 pm
Reply with quote

Hi All,

I am running below mentioned sort step:

Code:
//SORT0010 EXEC PGM=SORT                   
//SYSOUT   DD  SYSOUT=*                     
//SYSUDUMP DD  SYSOUT=*                     
//SYSPRINT DD  SYSOUT=*                     
//SORTIN   DD DSN=HLQ1.HLQ2.SX.PA.REGION,   
//            DISP=SHR,                     
//            DCB=(LRECL=80,RECFM=FB)       
//         DD DSN=HLQ1.HLQ2.SX.PA.REGION.PD,
//            DISP=SHR,                     
//            DCB=(LRECL=80,RECFM=FB)       
//         DD DSN=HLQ1.HLQ2.SX.VPALORC.PS, 
//            DISP=SHR,                     
//            DCB=(LRECL=80,RECFM=FB)       
//SORTOUT DD SYSOUT=*                       
//SYSIN   DD *                             
  SORT FIELDS=(1,19,BI,A),FILES=3           
  RECORD TYPE=F,LENGTH=(80)                 
//*                                         


Data in the input files is

File 1:

Code:
----+----1----+----2----
0073020193233193233A0000
0073020193233193233B0001
XXXXXBBBBBPPPPPQQQQA0000
XXXXXBBBBBPPPPPQQQQB0001


File 2:

Code:
----+----1----+----2----
XXXXXBBBBBPPPPPQQQQA0003
XXXXXBBBBBPPPPPQQQQB0002
SDFHJKLAHBPPPPPQQQQA0000
SDFHJKLAHBPPPPPQQQQB0001


File 3:

Code:
----+----1----+----2----
0073020193233193233A0004
0073020193233193233B0005
WQEUROQWEI233193233A0000
WQEUROQWEI233193233B0001


I was expecting the output as mentioned below:

Code:
SDFHJKLAHBPPPPPQQQQA0000
SDFHJKLAHBPPPPPQQQQB0001
WQEUROQWEI233193233A0000
WQEUROQWEI233193233B0001
XXXXXBBBBBPPPPPQQQQA0000
XXXXXBBBBBPPPPPQQQQB0001
XXXXXBBBBBPPPPPQQQQA0003
XXXXXBBBBBPPPPPQQQQB0002
0073020193233193233A0000
0073020193233193233B0001
0073020193233193233A0004
0073020193233193233B0005


On each run I am getting the output in random sequence.

My output is,

Run 1:

Code:
SDFHJKLAHBPPPPPQQQQA0000
SDFHJKLAHBPPPPPQQQQB0001
WQEUROQWEI233193233A0000
WQEUROQWEI233193233B0001
XXXXXBBBBBPPPPPQQQQA0003
XXXXXBBBBBPPPPPQQQQA0000
XXXXXBBBBBPPPPPQQQQB0001
XXXXXBBBBBPPPPPQQQQB0002
0073020193233193233A0000
0073020193233193233A0004
0073020193233193233B0005
0073020193233193233B0001


Run 2:

Code:
SDFHJKLAHBPPPPPQQQQA0000
SDFHJKLAHBPPPPPQQQQB0001
WQEUROQWEI233193233A0000
WQEUROQWEI233193233B0001
XXXXXBBBBBPPPPPQQQQA0000
XXXXXBBBBBPPPPPQQQQA0003
XXXXXBBBBBPPPPPQQQQB0001
XXXXXBBBBBPPPPPQQQQB0002
0073020193233193233A0004
0073020193233193233A0000
0073020193233193233B0005
0073020193233193233B0001


Please see the last 4 records.

I know that SORT will not assure the order/sequence, but I need my output in the same order.

Can anyone help me out to get the sorted data in the order?


Thanks,
Satish
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Apr 02, 2012 4:21 pm
Reply with quote

for <duplicate> keys the order is unpredictable,
the only workaround is to use OPTION EQUALS
which will for <duplicate> keys preserve the original relative sequence
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Mon Apr 02, 2012 5:02 pm
Reply with quote

Hello,

I have tested your snippet, worked for me.

Anyhow try this,

Code:
//SORT0010 EXEC PGM=ICETOOL                                     
//DFSMSG   DD  SYSOUT=*                                         
//TOOLMSG  DD  SYSOUT=*                                         
//SYSOUT   DD  SYSOUT=*                                         
//IN1      DD DSN=TEST.INPUT.FILE1,DISP=SHR,         
//             LRECL=80,RECFM=FB                                 
//         DD DSN=TEST.INPUT.FILE2,DISP=SHR,         
//             LRECL=80,RECFM=FB                                 
//         DD DSN=TEST.INPUT.FILE3,DISP=SHR,         
//             LRECL=80,RECFM=FB                                 
//OUT1    DD SYSOUT=*                                           
//TOOLIN  DD *                                                   
  SORT FROM(IN1) TO(OUT1) USING(CTL1)                           
/*                                                               
//CTL1CNTL DD *                                                 
  SORT FIELDS=(1,19,BI,A)   
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Apr 02, 2012 5:13 pm
Reply with quote

xknight wrote:
[...]

I have tested your snippet, worked for me.

[...]


Maybe your site has EQUALS as the installation default?
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Mon Apr 02, 2012 5:21 pm
Reply with quote

Quote:
Maybe your site has EQUALS as the installation default?


May be you are correct bill. Suppose it should icon_idea.gif
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Mon Apr 02, 2012 5:21 pm
Reply with quote

The default value for the SAS SORT proc is EQUALS.

I think this is a terrible idea. Novices and even some with experience will assume this is standard sort behavior across all sort programs.

I suggest never relying on this as a default value, but rather always specifying EQUALS when you want/need it.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Apr 02, 2012 6:34 pm
Reply with quote

satish.ms10 wrote:
[...]
Code:
  SORT FIELDS=(1,19,BI,A),FILES=3           
  RECORD TYPE=F,LENGTH=(80)                 
//* 

[...]


I have to say this is a little odd. I'd have thought FILES=3 would be for a MERGE. The LENGTH is likely going to be ignored, as is the TYPE, or are you reading VSAM? Maybe it is a very old sort deck?
Back to top
View user's profile Send private message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Mon Apr 02, 2012 8:06 pm
Reply with quote

Hi All,

Many Thanks for your kind response.

It worked with OPTION EQUALS.

Thanks Again.

-Sati
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 Apr 02, 2012 10:42 pm
Reply with quote

Quote:
have to say this is a little odd. I'd have thought FILES=3 would be for a MERGE. The LENGTH is likely going to be ignored, as is the TYPE


FILES=n is ignored by DFSORT unless you are doing a MERGE with all of the records inserted by an E32 exit.

LENGTH and TYPE will be ignored here also since DFSORT can obtain them from the SORTIN data set.
Back to top
View user's profile Send private message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Tue Apr 03, 2012 4:00 pm
Reply with quote

Hi Frank,

I have removed FILES, LENGTH and TYPE options from the SORT card.

Many Thanks for you suggestion.

Thanks,
Saish
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 Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top