Page 2 of 2

Re: Clarification Needed in Sorting

PostPosted: Thu Oct 04, 2012 8:42 pm
by gowthamgyaa
Thank you very much nicc.


Kind regards
gyaa

Re: Clarification Needed in Sorting

PostPosted: Thu Oct 04, 2012 8:43 pm
by dick scherrer
Hello,

Have the sort control statements now been changed to match the data? Has this run successfully?

If yes, please post your working solution. If there is still a problem, post what is the problem?

Re: Clarification Needed in Sorting

PostPosted: Thu Oct 04, 2012 8:48 pm
by gowthamgyaa
Hi Dicc sherrer,
Thanks for your kind reply.
Actually sorting is been done correctly but sum field's is the one which i cant clearly understand.
In the above mention JCL statements when i use sumfields its summing both MEC and MMM.
Kindly guide me in this.


Kind regards
gyaa

Re: Clarification Needed in Sorting

PostPosted: Thu Oct 04, 2012 8:53 pm
by NicC
IF your SUM FIELDS is specifying 4,2 as per your original post then it will sum ' MMM' and ' MEC' (note the blanks before the first Ms) because column 4 for 2 characters is ' M' for both records. if you really mean to sort on column 5 for 2 characters then the only records that will sum are the 2 CSE records which would give 2227.

Re: Clarification Needed in Sorting

PostPosted: Thu Oct 04, 2012 9:31 pm
by dick scherrer
Hello,

In the above mention JCL statements when i use sumfields its summing both MEC and MMM.
The process is SUMming as you coded. It can only do what we tell it. To get the answer you want, you need to correct the positions you specify for the SORT/SUM.

Re: Clarification Needed in Sorting

PostPosted: Thu Oct 04, 2012 9:48 pm
by skolusu
gowthamgyaa,

Use the following DFSORT JCL. I assumed that your input is RECFM=FB . If your input RECFM is VB or V then you may need to add 4 bytes to the actual positions as the first 4 bytes have the RDW.
//STEP0100 EXEC PGM=SORT   
//SYSOUT   DD SYSOUT=*     
//SORTIN   DD *           
----+----1----+----2----+--
001 CSE 1005               
002 ECE 1111               
008 MEC 1007               
014 CSE 1222               
0777AAA 1453               
088 SSS 1000               
015 MMM 1005               
//SORTOUT  DD SYSOUT=*     
//SYSIN    DD *           
  OPTION ZDPRINT           
  SORT FIELDS=(5,3,CH,D)   
  SUM FIELDS=(9,4,ZD)     
//*


The output from this is
088 SSS 1000
015 MMM 1005
008 MEC 1007
002 ECE 1111
001 CSE 2227
0777AAA 1453