IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

help needed in dupkeys max option


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jemonthomas

New User


Joined: 24 Jul 2006
Posts: 35
Location: india

PostPosted: Tue Mar 31, 2009 2:33 pm
Reply with quote

I need a column max value when duplicates come.It is a comp field.please help
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Mar 31, 2009 2:48 pm
Reply with quote

Hello,

Why do you have a duplicate post, which SORT product you are using?
Back to top
View user's profile Send private message
jemonthomas

New User


Joined: 24 Jul 2006
Posts: 35
Location: india

PostPosted: Tue Mar 31, 2009 2:50 pm
Reply with quote

dfsort
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Mar 31, 2009 10:04 pm
Reply with quote

Jemonthomas,

There are many ways to get the max dup record. The following are your control cards

Code:

 SORT FIELDS=(1,10,CH,A,11,4,BI,A,15,8,CH,A)
 DUPKEYS MAX=(23,4,BI)


Since all the SORT fields in your control cards are continous fields we can club them into a single field and sort it as binary. Since you want to get the max value , you can sort on the filed 23,4,bi Ascending and the last value will be max value record. Trailer3 will pull the last record for each key (1,22)

Code:

//STEP0100 EXEC PGM=SORT               
//SYSOUT   DD SYSOUT=*                 
//SORTIN   DD *                         
----+----1----+----2----+----3----+----4
A                     1000             
A                     9000             
A                     7000             
A                     8000             
B                     6000             
B                     3000             
B                     1000             
//SORTOUT  DD SYSOUT=*                 
//SYSIN    DD *                         
  OPTION EQUALS                         
  SORT FIELDS=(01,22,BI,A,             
               23,04,BI,A)             
                                       
  OUTFIL REMOVECC,NODETAIL,             
  SECTIONS=(1,22,TRAILER3=(1,80))       
/*



Alternatively you can sort on the 23,4,bi descending so that the Max value is the first record for every group. using RESTART parm we number the duplicates and pick only the first record which is the max value record.

Code:

//STEP0100 EXEC PGM=SORT                         
//SYSOUT   DD SYSOUT=*                           
//SORTIN   DD *                                 
A                     1000                       
A                     9000                       
A                     7000                       
A                     8000                       
B                     6000                       
B                     3000                       
B                     1000                       
//SORTOUT  DD SYSOUT=*                           
//SYSIN    DD *                                 
  OPTION EQUALS                                 
  SORT FIELDS=(01,22,BI,A,                       
               23,04,BI,D)                       
                                                 
  OUTREC OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,22))
  OUTFIL BUILD=(1,80),INCLUDE=(81,8,ZD,EQ,1)     
/*


or
If you think the idea of numbering the duplicates is cumbersome, you can use the DFSORT/ICETOOL's SELECT operator which lets you pick the record you want. In this case we want the first record when the max value is sorted descending.

Code:

//STEP0300 EXEC PGM=ICETOOL                             
//TOOLMSG  DD SYSOUT=*                                 
//DFSMSG   DD SYSOUT=*                                 
//IN       DD *                                         
A                     1000                             
A                     9000                             
A                     7000                             
A                     8000                             
B                     6000                             
B                     3000                             
B                     1000                             
//OUT      DD SYSOUT=*                                 
//TOOLIN   DD *                                         
  SELECT FROM(IN) TO(OUT) ON(1,22,BI) FIRST USING(CTL1)
//CTL1CNTL DD *                                         
  SORT FIELDS=(01,22,BI,A,                             
               23,04,BI,D)                             
/*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts SCOPE PENDING option -check data DB2 2
No new posts OUTFIL with SAVE option DFSORT/ICETOOL 7
No new posts CICS vs LE: STORAGE option CICS 0
No new posts Mainframe Programmer with CICS Skill... Mainframe Jobs 0
No new posts INSYNC option with same function as I... JCL & VSAM 0
Search our Forums:

Back to Top