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

Need help in SORT and getting the record with latest date


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

New User


Joined: 23 Oct 2006
Posts: 24
Location: India

PostPosted: Tue Oct 26, 2010 9:59 pm
Reply with quote

Hi All,

Need help from you on the below scenario.

I/P File

Record No(10 Char) Suffix (04 Char) Filler(06 Char) Date (08Char)

0000000001|aaaa|rec001|20101010
0000000001|aaaa|rec002|20101014
0000000002|bbbb|rec002|20101012
0000000003|cccc|rec003|20101014
0000000003|cccc|rec003|20101018

Output File:

0000000001|aaaa|rec002|20101014
0000000002|bbbb|rec002|20101012
0000000003|cccc|rec003|20101018

Requirement: I need to sort the record with Record number and Suffix ( Ascending).
If there is two records with same Record# and Suffix then Verify the date. Take the record which is having the latest date and write to output file.

Thanks in advance for your timely help.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Tue Oct 26, 2010 10:12 pm
Reply with quote

jegan_selvan,
See if below works for you...

Code:
//STEP01   EXEC PGM=ICETOOL                                           
//IN        DD *                                                     
0000000001|AAAA|REC001|20101010                                       
0000000001|AAAA|REC002|20101014                                       
0000000002|BBBB|REC002|20101012                                       
0000000003|CCCC|REC003|20101014                                       
0000000003|CCCC|REC003|20101018                                       
//OUT       DD SYSOUT=*                                               
//TOOLIN    DD *                                                     
SELECT FROM(IN) TO(OUT) ON(1,10,CH) ON(12,04,CH) FIRST USING(CTL1)   
/*                                                                   
//CTL1CNTL DD *                                                       
 SORT FIELDS=(01,10,CH,A,12,04,CH,A,24,08,CH,D)                       
/*                                                                   
//TOOLMSG   DD  SYSOUT=*                                             
//DFSMSG    DD  SYSOUT=*                                             


OUTPUT
Code:
0000000001|AAAA|REC002|20101014
0000000002|BBBB|REC002|20101012
0000000003|CCCC|REC003|20101018


Thanks,
Back to top
View user's profile Send private message
jegan_selvan

New User


Joined: 23 Oct 2006
Posts: 24
Location: India

PostPosted: Tue Oct 26, 2010 10:32 pm
Reply with quote

Thanks a lot. Working to my requirement.

Regards,

Jegan S
Back to top
View user's profile Send private message
jegan_selvan

New User


Joined: 23 Oct 2006
Posts: 24
Location: India

PostPosted: Fri Oct 29, 2010 5:25 pm
Reply with quote

Hi All,

I need one more additional requirement on the same itself.

Already Done: I need to sort the record with Record number and Suffix ( Ascending).
If there is two records with same Record# and Suffix then Verify the date. Take the record which is having the latest date and write to output file

Additional One:

1. I need to sort the record with Record number and Suffix ( Ascending).
If there is two records with same Record# and Suffix then Verify the date. Take the record which is having the latest date and write to output file
2. I need to write the skipped record with older date ( as XDUP) as different file.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Fri Oct 29, 2010 6:49 pm
Reply with quote

jegan_selvan,
Use below... All the skipped records are written to XSUM dataset.
Code:
//STEP01   EXEC PGM=ICETOOL                         
//IN        DD *                                     
0000000001|AAAA|REC001|20101010                     
0000000001|AAAA|REC002|20101014                     
0000000002|BBBB|REC002|20101012                     
0000000003|CCCC|REC003|20101014                     
0000000003|CCCC|REC003|20101018                     
//OUT       DD SYSOUT=*                             
//XSUM      DD SYSOUT=*                             
//TOOLIN    DD *                                     
 SELECT FROM(IN) TO(OUT) ON(1,10,CH) ON(12,04,CH) - 
 FIRST DISCARD(XSUM) USING(CTL1)                     
/*                                                   
//CTL1CNTL DD *                                     
 SORT FIELDS=(01,10,CH,A,12,04,CH,A,24,08,CH,D)     
/*                                                   
//TOOLMSG   DD  SYSOUT=*                             
//DFSMSG    DD  SYSOUT=*                             


Thanks,
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
Search our Forums:

Back to Top