Page 1 of 1

Maximum value of a field!!!!

PostPosted: Mon May 14, 2012 11:46 pm
by ibmmf4u
Hi Everyone,

My Requirement goes this way , I need to retrieve the maximum value of a field and write it to an output file.

Inputfile:-

0100
0500
0700
0900


Outputfile:-



Can some one please help me out in achieving the same with syncsort.

Thanks in advance!!!!

Re: Maximum value of a field!!!!

PostPosted: Tue May 15, 2012 12:01 am
by BillyBoyo
If you sort you can get the largest value into a specific position (first or last) in the data. There are then various ways to ensure you only get the first/last.

Have a look at your manual and see what you can find which might be useful.

Re: Maximum value of a field!!!!

PostPosted: Tue May 15, 2012 12:16 am
by ibmmf4u
Hi Bill,

Thanks for the guidance . Below piece of code is working fine for my requirement.

//STEP010  EXEC PGM=SORT
//SORTIN   DD *         
0200                   
0500                   
0800                   
0300                   
1300                   
1100                   
1600                   
//SORTOUT  DD SYSOUT=* 
//SYSOUT   DD SYSOUT=* 
//SYSIN    DD *         
  SORT FIELDS=(1,4,CH,D)
  OUTFIL ENDREC=1       
/*                     


The output file contains only the first maximum record.

Outputfile:-


Thanks for helping me out!!!!

Re: Maximum value of a field!!!!

PostPosted: Tue May 15, 2012 12:33 am
by BillyBoyo
Only took you 15 minutes as well, impressive. Well done.

Re: Maximum value of a field!!!!

PostPosted: Tue May 15, 2012 9:34 pm
by ibmmf4u
Thank you Bill. Its all because of the guidance from you.

Thanks for your help!!!