MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sorting Timestamp

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
jayram99
Beginner


Joined: 16 Aug 2004
Posts: 52
Topics: 21
Location: falls church.va,usa

PostPosted: Fri Jul 13, 2018 9:35 am    Post subject: Sorting Timestamp Reply with quote

Hi All,

I need to sort duplicate records and keep the latest one record. The format of timestamp DDMMMYYYY:HH:MM:SS:NNNNNN
Code:

1234567 ABCDEF 1.00000000  .          13APR2017:00:01:43.894091
1234567 ABCDEF 1.00000000 0.00000000  11JUL2018:23:59:11.117038
1234567 ABCDEF 0.00000000 1.00000000  11JUL2018:23:59:11.126017

O/P
Code:

1234567 ABCDEF 0.00000000 1.00000000  11JUL2018:23:59:11.126017


I tried with CH option and SUM FIELDS=NONE to keep the latest record but didn't worked only for this record
Code:

SORT  FIELDS=(1,7,CH,A,9,6,CH,A,39,25,CH,D)

SUM FIELDS=NONE


Please advise me if we can sort Timestamp with the above format.

jayaram
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jul 13, 2018 11:48 am    Post subject: Reply with quote

jayram99,

1. You have been a member of this forum for a long time and by now you should know how to use CODE tags. I added them for you this time but make sure you follow the rules.

2. The timestamp you show is NOT a standard format. You need to convert the 3 character month name to 2 digit month number and then re-arrange the timestamp to the format YYYYMMDD:time format.

3. Your SUM FIELD=NONE will not work as you are sorting on 2 Fields and unless both of the fields are duplicates you will not discard any duplicates.

Assuming your input file has an LRECL of 80 and RECFM of FB use the following DFSORT/ICETOOL JCL which will give you the desired results. If your input has RECFM=VB then you need to put the modified timestamp right after the RDW so as to preserve the Variable length records.

Code:

//STEP0100 EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                                 
//DFSMSG   DD SYSOUT=*                                                 
//IN       DD *                                                       
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
1234567 ABCDEF 1.00000000 .           13APR2017:00:01:43.894091       
1234567 ABCDEF 1.00000000 0.00000000  11JUL2018:23:59:11.117038       
1234567 ABCDEF 0.00000000 1.00000000  11JUL2018:23:59:11.126017       
//OUT      DD SYSOUT=*                                                 
//TOOLIN   DD *                                                       
  SELECT FROM(IN) TO(OUT) ON(1,7,CH) FIRST USING(CTL1)                 
//CTL1CNTL DD *                                                       
  INREC OVERLAY=(81:44,04,                            $ YEAR           
                    41,03,CHANGE=(2,C'JAN',C'01',     $ JAN TO 01     
                                    C'FEB',C'02',     $ FEB TO 02     
                                    C'MAR',C'03',     $ MAR TO 03     
                                    C'APR',C'04',     $ APR TO 04     
                                    C'MAY',C'05',     $ MAY TO 05     
                                    C'JUN',C'06',     $ JUN TO 06     
                                    C'JUL',C'07',     $ JUL TO 07     
                                    C'AUG',C'08',     $ AUG TO 08     
                                    C'SEP',C'09',     $ SEP TO 09     
                                    C'OCT',C'10',     $ OCT TO 10     
                                    C'NOV',C'11',     $ NOV TO 11     
                                    C'DEC',C'12'),    $ DEC TO 12     
                          NOMATCH=(C'00'),                             
                    39,02,                            $ DAY           
                    48,16)                            $ TIME           
                                                                       
  SORT FIELDS=(01,07,CH,A,                            $ KEY-1         
               81,24,CH,D)                            $ TIMESTAMP     
                                                                       
                                                                       
  OUTFIL BUILD=(1,80)                                                 
//*                                                                   

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group