Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Compare yesterday's date to the one o... migusd SYNCSORT 8 Fri Sep 22, 2017 11:35 pm
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
No new posts Validate the Date girishb2 DFSORT/ICETOOL 9 Tue Sep 19, 2017 1:12 am
No new posts OC4 in SORT Mohan Kothakota DFSORT/ICETOOL 2 Tue Sep 12, 2017 6:30 pm
No new posts Julian Date to CICS ABSTTIME blayek CICS 3 Wed Aug 30, 2017 11:15 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us