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
 

 

Keep latest record for each key....

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Apr 10, 2009 5:50 pm    Post subject: Keep latest record for each key....
Reply with quote

Hi
i have file with following layout
1,5-constant
6,1-operation(I\U\D)
7,5-key
12,9-other details

I want last record in the file for each key....
I have tried below code.... and its working fine.. But If somebody could give more efficient solution that would be great.

Code:

//CRP  DD *                                 
05CRPICRP01ABC LTD.                         
05CRPICRP02XYZ LTD.                         
05CRPUCRP01DEF LTD.                         
05CRPDCRP01DEF LTD.                         
05CRPICRP03ABC LTD.                         
05CRPICRP02XXX LTD.                         
/*                                           
//TMP   DD  DSN=&&TEMP,DISP=(NEW,PASS)       
//TMP1  DD  DSN=&&TEMP1,DISP=(NEW,PASS)     
//CRPO   DD  SYSOUT=*                       
//TOOLIN DD *                               
  SORT FROM(CRP) TO(TMP) USING(CTL1)         
  SORT FROM(TMP) TO(TMP1) USING(CTL2)       
  SORT FROM(TMP1) TO(CRPO) USING(CTL3)       
/*                                           
//CTL3CNTL DD *                                       
  SORT FIELDS=(1,5,CH,A,7,5,CH,A)                     
  SUM FIELDS=NONE                                     
  OUTREC FIELDS=(1,20)                               
/*                                                   
//CTL2CNTL DD *                                       
  SORT FIELDS=(1,5,CH,A,7,5,CH,A,21,3,ZD,D)           
/*                                                   
//CTL1CNTL DD *                                       
  SORT FIELDS=(1,5,CH,A,7,5,CH,A)                     
  OUTREC FIELDS=(1,20,SEQNUM,3,ZD,RESTART=(7,5))     
/*                                                   


Output expected is:
Code:

05CRPDCRP01DEF LTD.
05CRPICRP02XXX LTD.
05CRPICRP03ABC LTD.
Back to top
View user's profile Send private message

Skolusu

Senior Member


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

PostPosted: Fri Apr 10, 2009 8:08 pm    Post subject: Reply to: Keep latest record for each key....
Reply with quote

Sambhaji,

You had made it way complicated than it needs to be. A simple SELECT with LAST parm will give you the desired results or SECTIONS with TRAILER3 will give you the desired results.

Code:

//STEP0100 EXEC PGM=ICETOOL               
//TOOLMSG  DD SYSOUT=*                   
//DFSMSG   DD SYSOUT=*                   
//IN       DD *                           
05CRPICRP01ABC LTD.                       
05CRPICRP02XYZ LTD.                       
05CRPUCRP01DEF LTD.                       
05CRPDCRP01DEF LTD.                       
05CRPICRP03ABC LTD.                       
05CRPICRP02XXX LTD.                       
//OUT      DD SYSOUT=*                   
//TOOLIN   DD *                           
  SELECT FROM(IN) TO(OUT) ON(7,5,CH) LAST
/*                                       


or

Code:

//STEP0100 EXEC PGM=SORT           
//SYSOUT   DD SYSOUT=*             
//SORTIN   DD *                   
05CRPICRP01ABC LTD.               
05CRPICRP02XYZ LTD.               
05CRPUCRP01DEF LTD.               
05CRPDCRP01DEF LTD.               
05CRPICRP03ABC LTD.               
05CRPICRP02XXX LTD.               
//SORTOUT  DD SYSOUT=*             
//SYSIN    DD *                   
  OPTION EQUALS                   
  SORT FIELDS=(7,5,CH,A)           
  OUTFIL REMOVECC,NODETAIL,       
  SECTIONS=(7,5,TRAILER3=(1,20))   
/*                                 
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Fri Apr 10, 2009 8:19 pm    Post subject:
Reply with quote

Thanks kolusu,

This forum and People here are great... [icon_smile.gif]
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 Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 5 Wed Jul 26, 2017 7:35 pm
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm


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