How to pick the last record if all the records are same



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

How to pick the last record if all the records are same

Postby pgkkreddy1 » Tue Mar 29, 2016 10:58 pm

Hi All,
Good evening.
I have 3 records with same values in file and I want to pick last record in the file. Setting the sequence num is one way, is there any other way to do this. Please suggest

Records in file are like below
05 3333 1604 N
05 3333 1604 Y
05 3333 1604

I am sorting based on only first 3 fields .

Regards,
kk
pgkkreddy1
 
Posts: 18
Joined: Wed May 13, 2015 8:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to pick the last record if all the records are same

 

Re: How to pick the last record if all the records are same

Postby Aki88 » Wed Mar 30, 2016 11:33 am

Hello,

pgkkreddy1 wrote:I am sorting based on only first 3 fields .

Check the SUBSET operator of ICETOOL, it has various functions which can be used to achieve what you're looking for.
Since you're SORTing the data on first three bytes, hence the added SORT statement:

//TESTRUN  EXEC PGM=ICETOOL                          
//TOOLMSG  DD SYSOUT=*                                
//DFSMSG   DD SYSOUT=*                                
//IN       DD *                                      
05 3333 1604 N                                        
05 3333 1604 Y                                        
05 3333 1604                                          
/*                                                    
//OUT      DD SYSOUT=*                                
//TOOLIN   DD *                                      
 SUBSET FROM(IN) TO(OUT) KEEP OUTPUT LAST USING(CTL1)
/*                                                    
//CTL1CNTL DD *                                      
 SORT FIELDS=(1,3,CH,A)                              
/*                                                    

Output:


05 3333 1604
 


Hth.
Aki88
 
Posts: 351
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 34 times

Re: How to pick the last record if all the records are same

Postby BillyBoyo » Wed Mar 30, 2016 11:55 am

Your editor?

Why do you want to SORT three records with the same key? Do you want to keep them in the original input sequence, or whatever the output from SORT gives you?

SUBSET can be used for this, SELECT can be used for this (and can operate on keys), OUTFIL reporting features can be used for this (REMOVECC, NODETAIL, SECTIONS with TRAILER3).

However, why not your editor?

Explain more, please.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 262 times

Re: How to pick the last record if all the records are same

Postby pgkkreddy1 » Wed Mar 30, 2016 3:35 pm

Thanks very much for reply.
My requirement is to load the latest record. Based on those fields. i.e from input file last dup record. Input file I can't edit it is from some other source.

Actually I kept sequence for all the records
sort all three fields in ascending order and sequence number in descending order.
so last dup record comes to first. Then I used sort xsum and first record pick in the out file.

once again thank you

Regards,
kk
pgkkreddy1
 
Posts: 18
Joined: Wed May 13, 2015 8:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to pick the last record if all the records are same

Postby BillyBoyo » Wed Mar 30, 2016 4:18 pm

For three records, I suppose it doesn't matter much, but that's not an effective general way to do it.

XSUM means you are using SyncSORT, so topic moved to the correct part of the forum.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 262 times

Re: How to pick the last record if all the records are same

Postby c62ap90 » Fri Apr 08, 2016 8:03 am

I did not try it out but maybe...
//SYSIN DD *
SORT FIELDS=(1,3,CH,A)
DUPKEYS LASTDUP,NODUPS
c62ap90
 
Posts: 125
Joined: Thu Oct 11, 2012 10:24 pm
Has thanked: 1 time
Been thanked: 6 times

Re: How to pick the last record if all the records are same

Postby BillyBoyo » Fri Apr 08, 2016 12:01 pm

Yeah, 'cept the data is already in sequence. Why SORT it again?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 262 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post