Page 1 of 1

How to BEGIN this GROUP

PostPosted: Fri Apr 01, 2011 7:20 pm
by ricklennox
Hi - Sorry if this has been covered elsewhere, but I've gone through DFSORT application guides and the Smart Tricks guide and haven't found a solution.

Records have two key fields (in positions 1 and 3) and unpredictable numeric data (in position 5) :
a a 1
a a 1
a a 2
a a 5
a b 1
a b 6
b a 1
b a 2
b a 9

After sorting the records on the keys (ascending) and the numeric data (descending), I'd like to group the records by the keys and propagate the highest numeric value to the group (red records have changed numeric value) :
a a 5
a a 5 (was 'a a 2')
a a 5 (was 'a a 1')
a a 5 (was 'a a 1')
a b 6
a b 6 (was 'a b 1')
b a 9
b a 9 (was 'b a 2')
b a 9 (was 'b a 1')

My problem is, I have nothing fixed to give the BEGIN in order to propagate the value within the GROUP.

Re: How to BEGIN this GROUP

PostPosted: Fri Apr 01, 2011 9:21 pm
by skolusu
ricklennox,

Use the following DFSORT JCL which will give you the desired results

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
----+----1----+----2----+----3----+----4----+----5----+--
A A 1                                                   
A A 1                                                   
A A 2                                                   
A A 5                                                   
A B 1                                                   
A B 6                                                   
B A 1                                                   
B A 2                                                   
B A 9                                                   
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  SORT FIELDS=(1,3,CH,A,5,1,CH,D),EQUALS                 
  OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,3),PUSH=(5:5,1))
//*

Re: How to BEGIN this GROUP

PostPosted: Fri Apr 01, 2011 11:30 pm
by ricklennox
Thank you very much. I didn't know there was a KEYBEGIN, I'll have to look that up.

Re: How to BEGIN this GROUP

PostPosted: Fri Apr 01, 2011 11:47 pm
by Frank Yaeger
KEYBEGIN is a new DFSORT function available with the Oct, 2010 DFSORT PTF. For more information, see:

http://www.ibm.com/support/docview.wss? ... g3T7000242