MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
chirag2901 Beginner Joined: 19 Apr 2006 Posts: 7 Topics: 4
Posted: Sun Apr 23, 2006 8:53 pm Post subject: Adding times using Dfsort/Icetool
Hi guys,
I have an input file with two columns. Both are times. Format is as below:
Code: 00:01:00 14:00:00
00:02:00 07:00:00
00:01:00 20:30:00
I want to add a third column, which is the addition of first and second column.
e.g. Output:
Code: 00:01:00 14:00:00 14:01:00
00:02:00 07:00:00 07:02:00
00:01:00 20:30:00 20:31:00
Any way to do this using dfsort / icetool ?
Thanks,
Chirag
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
Posted: Mon Apr 24, 2006 5:01 am Post subject:
chirag2901 ,
Adding 2 times is easy but you need to define the rules. what happens if the sum of 2 times is greater than 24 hours? do you want the sum as 1 day 10 hours and 35 minutes and 22 seconds or 34 hours 35 minutes and 22 seconds.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
chirag2901 Beginner Joined: 19 Apr 2006 Posts: 7 Topics: 4
Posted: Mon Apr 24, 2006 5:32 am Post subject:
Hi Kolusu, tx. for your reply.
I think I will go with the second option. 34 hours, 25 min. , 20 seconds.
thanks,
chirag
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
Posted: Mon Apr 24, 2006 8:13 am Post subject:
chirag2901 ,
The following DFSORT JCL will give you the desired results. We first convert the both times into seconds and then add up and finally arrive at a number with total seconds. From that we derive the time back using the following calculation.
Code:
time in seconds = nnnnnnn
days = time / 86400
hours = (time / 3600) - (days * 24)
minutes = (time / 60) - (days * 1440) - (hours * 60)
seconds = time mod 60
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
00:01:00 14:00:00
00:02:00 07:00:00
00:01:32 20:30:00
13:41:52 15:30:59
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(20:+3600,MUL,01,02,ZD,ADD,
+0060,MUL,04,02,ZD,ADD,
07,2,ZD,ADD,
+3600,MUL,10,02,ZD,ADD,
+0060,MUL,13,02,ZD,ADD,
16,2,ZD,M11,LENGTH=8,X,
20,08,ZD,DIV,+86400,M11,LENGTH=8,X,
(20,08,ZD,DIV,+3600),M11,LENGTH=8,X,
(20,08,ZD,DIV,+60),SUB,
(29,8,ZD,MUL,+1440),SUB,
(38,8,ZD,MUL,+60),M11,LENGTH=8,X,
20,8,ZD,MOD,+60,M11,LENGTH=8)
OUTREC BUILD=(01:01,19,
20:38,8,ZD,M11,LENGTH=2,
22:C':',
23:47,8,ZD,M11,LENGTH=2,
25:C':',
26:56,8,ZD,M11,LENGTH=2)
/*
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
advoss Beginner Joined: 23 Aug 2005 Posts: 26 Topics: 0
Posted: Mon Apr 24, 2006 11:33 am Post subject:
I think something is wrong...
The answer for the fourth one should be 29:12:51, but Kolusu's script gives an answer of 29:28:51. _________________ Alan Voss
Back to top
advoss Beginner Joined: 23 Aug 2005 Posts: 26 Topics: 0
Posted: Mon Apr 24, 2006 12:00 pm Post subject:
Update to my last note.
I believe that line 10 of the INREC statement should be:
(29,8,ZD,MUL,+60),SUB, _________________ Alan Voss
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
Posted: Mon Apr 24, 2006 12:48 pm Post subject:
advoss ,
advoss,
Thanks for correcting me. I made a mistake while caluculating the time.
Here are the modified control cards.
Code:
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(20:+3600,MUL,01,02,ZD,ADD,
+0060,MUL,04,02,ZD,ADD,
07,2,ZD,ADD,
+3600,MUL,10,02,ZD,ADD,
+0060,MUL,13,02,ZD,ADD,
16,2,ZD,M11,LENGTH=8,X,
(20,08,ZD,DIV,+3600),M11,LENGTH=8,X,
(20,08,ZD,MOD,+3600),DIV,+60,M11,LENGTH=8,X,
20,8,ZD,MOD,+60,M11,LENGTH=8)
OUTREC BUILD=(1,19,
20:29,8,ZD,M11,LENGTH=2,
22:C':',
23:38,8,ZD,M11,LENGTH=2,
25:C':',
26:47,8,ZD,M11,LENGTH=2)
/*
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
boddapati_siva Beginner Joined: 25 Apr 2006 Posts: 1 Topics: 0
Posted: Sat Apr 29, 2006 4:19 am Post subject:
can u explain the code furthur
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
Posted: Sat Apr 29, 2006 11:25 am Post subject:
boddapati_siva ,
I am not sure what you mean by explain more. it is quite simple.
First convert the time into seconds
Code:
HH:MM:SS = (3600 * HH) + (60 * MM) + SS = TOTAL SECS
Perform the same formula for the second time also.
Code:
Grand total of secs = ( Total secs 1 + total secs 2)
Now to get the time back in HH:MM:SS use the following formula
Code:
HH = GRAND TOTAL SECS/ 3600
MM = (REMAINDER OF GRAND TOTAL SECS /3600) / 60
SS = (REMAINDER OF GRAND TOTAL SECS/60)
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
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