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
 

 

Sorted Data not in sequence

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

Active User


Joined: 10 Aug 2009
Posts: 158
Location: India

PostPosted: Mon Apr 02, 2012 4:07 pm    Post subject: Sorted Data not in sequence
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Apr 02, 2012 4:21 pm    Post subject: Reply to: Sorted Data not in sequence
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Mon Apr 02, 2012 5:13 pm    Post subject:
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    Post subject:
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

Active Member


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

PostPosted: Mon Apr 02, 2012 5:21 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Mon Apr 02, 2012 6:34 pm    Post subject: Re: Sorted Data not in sequence
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: 158
Location: India

PostPosted: Mon Apr 02, 2012 8:06 pm    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Apr 02, 2012 10:42 pm    Post subject:
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: 158
Location: India

PostPosted: Tue Apr 03, 2012 4:00 pm    Post subject:
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    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 Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
No new posts How to move a long alphanumeric data ... lind sh COBOL Programming 6 Mon Dec 05, 2016 7:51 pm
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm


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