Page 1 of 1

Why do we use multiple fields in SORT FIELDS?

PostPosted: Thu Nov 13, 2008 4:22 pm
by ranga_subham
Hi,

I am not able to understand this basic concept somehow ! Please help.

Below job produces same output for both steps. So, what is the use of mentioning multiple fields in SORT FIELDS?

//STEP0001 EXEC PGM=SORT                 
//SORTIN   DD *                           
KRITCHA 01 070175                         
ROSANAR 02 061585                         
MOHANRU 05 121288                         
VISHHNU 04 010175                         
ARINDAM 03 110772                         
//SYSOUT   DD SYSOUT=*                   
//SORTOUT  DD SYSOUT=*                   
//SYSIN    DD *                           
 SORT FIELDS=(1,7,CH,A,9,2,CH,A,12,6,CH,A)
/*                                       
//*                                       
//STEP0002 EXEC PGM=SORT                 
//SORTIN   DD *                           
KRITCHA 01 070175                         
ROSANAR 02 061585                         
MOHANRU 05 121288                         
VISHHNU 04 010175                         
ARINDAM 03 110772               
//SYSOUT   DD SYSOUT=*           
//SORTOUT  DD SYSOUT=*           
//SYSIN    DD *                 
 SORT FIELDS=(1,7,CH,A,12,6,CH,A)
/*                               


Output from STEP0001:
ARINDAM 03 110772
KRITCHA 01 070175
MOHANRU 05 121288
ROSANAR 02 061585
VISHHNU 04 010175


Output from STEP0002:
ARINDAM 03 110772
KRITCHA 01 070175
MOHANRU 05 121288
ROSANAR 02 061585
VISHHNU 04 010175


Would you please help me understanding this concept?

Thanks.

Re: Why do we use multiple fields in SORT FIELDS?

PostPosted: Thu Nov 13, 2008 7:37 pm
by Bill Dennis
The purpose of multiple sort fileds is to properly sequence multiple records with the same primary key ( 1-7 ). If ARINDAM had three records with unique values in columns 9 and 10 the results would be different.

Your sample is so small you don't see the effect.