Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

help needed in dupkeys max option

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: help needed in dupkeys max option
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

Senior Member


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

PostPosted: Tue Mar 31, 2009 2:48 pm    Post subject:
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    Post subject: Reply to: help needed in dupkeys max option
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    Post subject: Reply to: help needed in dupkeys max option
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts BWO option in VSAM blayek CICS 3 Sat Nov 05, 2016 10:47 am
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts Help Needed with View Direct shailesh_do CA Products 2 Wed Jul 13, 2016 10:39 am
No new posts Compiler option for override the exte... muralikrishnan_new COBOL Programming 9 Fri Jul 08, 2016 12:09 pm
No new posts ICETOOL higher option Anshul Das DFSORT/ICETOOL 14 Thu Apr 14, 2016 8:00 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us