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
 

 

Need help in SORT and getting the record with latest date

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Need help in SORT and getting the record with latest date
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: 578
Location: USA

PostPosted: Tue Oct 26, 2010 10:12 pm    Post subject:
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    Post subject: Reply to: Need help in SORT and getting the record with late
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    Post subject:
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: 578
Location: USA

PostPosted: Fri Oct 29, 2010 6:49 pm    Post subject:
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    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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm


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