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
 
Process only last key record in a file containing dup Keys

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

New User


Joined: 26 Sep 2013
Posts: 3
Location: India

PostPosted: Tue Oct 09, 2018 9:39 am    Post subject: Process only last key record in a file containing dup Keys
Reply with quote

Hi All,

I have been a silent follower of this forum and I have used lot of tips and resolutions posted by seniors on the different topics.

I just came across one scenario. I tried to search the forum for the same, but could not find( May be I have not used the exact word to search the forums). So posting it here.


I have an input file with below fields. When the file has duplicate keys, then It should process only the last key record in the output as shown below.


Code:
Key           Ref No     Last Changed Date
AAAA                7     2017-08-14
AAAA                7     9999-12-31
AAAA                8     9999-12-31     --> output
BBBB       2147483647     9999-12-31     --> output
CCCC                3     2012-06-19
CCCC                2     2012-06-16     --> output
DDDD                4     2017-06-10
DDDD                2     2016-09-17
DDDD                3     2018-10-09     --> output
EEEE                7     1998-01-20     
EEEE                6     2000-02-28     --> output



Can any one please let me know if we can achieve this using SORT ?

Thanks in Advance.

Regards,
Naveen
Back to top
View user's profile Send private message

Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1035
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Tue Oct 09, 2018 1:40 pm    Post subject:
Reply with quote

Hi,

I'd suggest looking at ICETOOLs' SELECT LAST or SELECT LASTDUP.

Garry.
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 388
Location: Maryland

PostPosted: Tue Oct 09, 2018 6:06 pm    Post subject:
Reply with quote

Code:
 OUTFIL NODETAIL,REMOVECC,
        SECTIONS=(1,5,
                  TRAILER3=(full record positions))
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2064
Location: NY,USA

PostPosted: Tue Oct 09, 2018 7:22 pm    Post subject:
Reply with quote

Quote:
I just came across one scenario. I tried to search the forum for the same, but could not find( May be I have not used the exact word to search the forums). So posting it here.
Sure you missed the Google look up. icon_smile.gif
http://ibmmainframes.com/about40127.html
http://ibmmainframes.com/about57520.html
http://ibmmainframes.com/about49085.html
http://ibmmainframes.com/about60697.html
Back to top
View user's profile Send private message
Naveen.katkuri24

New User


Joined: 26 Sep 2013
Posts: 3
Location: India

PostPosted: Wed Oct 10, 2018 10:05 am    Post subject:
Reply with quote

I have used the below code.

Code:
//IN      DD *
 AAAA                7     2017-08-14
 AAAA                7     9999-12-31
 AAAA                8     9999-12-31     
 BBBB       2147483647     9999-12-31
 CCCC                3     2012-06-19
 CCCC                2     2012-06-16     
 DDDD                4     2017-06-10
 DDDD                2     2016-09-17
 DDDD                3     2018-10-09     
 EEEE                7     1998-01-20     
 EEEE                6     2000-02-28   
 FFFF                 4    2010--08-31 
 GGGG               2     2012-03-13   
//TOOLIN   DD  *                             
  SELECT FROM(IN) TO(OUT) ON(2,6,PD) LASTDUP
/*

OUTPUT:

 AAAA                8     9999-12-31     
 CCCC                2     2012-06-16     
 DDDD                3     2018-10-09     
 EEEE                6     2000-02-28 




The above code is ignoring unique key records and processing only dup keys.

But my input file may contain unique and non-unique keys in the input file.
If there are non-unique records, then it should process last dup key along with unique key in the output. So could you please let me know if there is any other way to achieve this.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8747
Location: Welsh Wales

PostPosted: Wed Oct 10, 2018 11:38 am    Post subject:
Reply with quote

Click HERE see if the manuals that you could have read help you.

I found what you want in less than a minute icon_eek.gif
Back to top
View user's profile Send private message
Naveen.katkuri24

New User


Joined: 26 Sep 2013
Posts: 3
Location: India

PostPosted: Wed Oct 10, 2018 12:17 pm    Post subject:
Reply with quote

At last achieved my desired result with the below code.

OPTION EQUALS
SORT FIELDS=COPY
OUTFIL NODETAIL,REMOVECC,
SECTIONS(1,5,TRAILER3=(1,30))


Thanks a lot for your valuable inputs. especially @expat.
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1035
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Wed Oct 10, 2018 1:50 pm    Post subject:
Reply with quote

You didn't try:

Code:
  SELECT FROM(IN) TO(OUT) ON(2,6,PD) LAST


which I think is more readable than the solution you have.

Garry
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2064
Location: NY,USA

PostPosted: Wed Oct 10, 2018 7:02 pm    Post subject:
Reply with quote

Expat, Good one icon_smile.gif

Naveen, You got to open up those links I shared instead to overlook them and get to learn learn by yourself how it works.
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 How to process gdg in rexx program wh... pkmurali CLIST & REXX 11 Thu Dec 13, 2018 10:08 am
No new posts Transferring file to Mainframes Shinoj Vijayakumar IBM Tools 3 Thu Dec 06, 2018 2:35 pm
No new posts Convert VBA file to FB! Vignesh Sid SYNCSORT 5 Mon Dec 03, 2018 1:27 pm
No new posts Problem with OVERLAY - BI on SMF Record Ghellar DFSORT/ICETOOL 4 Sat Dec 01, 2018 9:41 pm
No new posts Propagating value from nth record to ... ganasrinivasan DFSORT/ICETOOL 7 Fri Nov 30, 2018 8:31 am

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