Sorting not giving desired output

JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...
mani_parashar
Posts: 2
Joined: Sat Oct 25, 2008 10:38 pm
Skillset: CICS,COBOL,DB2,JCL,REXX,VSAM
Referer: Google

Sorting not giving desired output

Postby mani_parashar » Sat Oct 25, 2008 11:54 pm

Hi All,

I have specific issue related to sort,as it is not giving a desired output.

Input File

Code: Select all

John    1080101   John    1080101   
He                John,   1080101
Is                John,   1080101 
a                 John,   1080101   
good              John,   1080101
boy.              John,   1080101
Donna   1070101   Donna   1070101   
She               Donna,  1070101
Is                Donna,  1070101 
a                 Donna,  1070101   
Queen             Donna,  1070101



The above file needs to be sorted in increasing order of name (Maximum 7 bytes long,1 byte of ",") (starts @42 byte) and decreasing order date of birth(starts @52 byte).

Desired Output

Code: Select all

Donna   1070101   Donna   1070101   
She               Donna,  1070101
Is                Donna,  1070101 
a                 Donna,  1070101   
Queen             Donna,  1070101
John    1080101   John    1080101   
He                John,   1080101
Is                John,   1080101 
a                 John,   1080101   
good              John,   1080101
boy.              John,   1080101




Please consider that file can extended to 1000(set) of records of same pattern.

I used the following sort control card

Code: Select all

  SORT FIELDSs =(42,8,CH,A,52,8,ZD,D)


Above sort resulted

Code: Select all

Donna   1070101   Donna   1070101   
Queen             Donna,  1070101
a                 Donna,  1070101   
Is                Donna,  1070101 
She               Donna,  1070101
John    1080101   John    1080101
boy.              John,   1080101
good              John,   1080101
a                 John,   1080101
Is                John,   1080101
He                John,   1080101

Please suggest what happened wrong in the sort control card,or is it that all the records being same at that specific position sort puts it in the any order (all being equivalent).

Thanks,
Mani

User avatar
dick scherrer
Global moderator
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am

Re: Sorting not giving desired output

Postby dick scherrer » Sun Oct 26, 2008 12:03 am

Hello,

You only specified 2 sort keys, so the sort only sorted on those 2 keys. Within the sorted keys, the sequence is unpredictable.

If you want the data to remain in the input order within the sort key(s), specify EQUALS.

Suggest only using EQUALS when the original sequence is required as it can degrade performance.
Hope this helps,
d.sch.

mani_parashar
Posts: 2
Joined: Sat Oct 25, 2008 10:38 pm
Skillset: CICS,COBOL,DB2,JCL,REXX,VSAM
Referer: Google

Re: Sorting not giving desired output

Postby mani_parashar » Sun Oct 26, 2008 2:34 pm

Thanks D.Sch,

Correct me I am wrong,you want my sort card should now look like this

Code: Select all

  OPTION EQUALS
  SORT FIELDS=(42,8,CH,A,52,8,ZD,D)


Please suggest.

Thanks,
Mani

User avatar
dick scherrer
Global moderator
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am

Re: Sorting not giving desired output

Postby dick scherrer » Sun Oct 26, 2008 2:49 pm

Hello,

Yes, that should work.

Also

Code: Select all

  SORT FIELDS=(42,8,CH,A,52,8,ZD,D),EQUALS


should provide the same result.

Good luck :)

d


  • Similar Topics
    Replies
    Views
    Last post