View previous topic :: View next topic
|
Author |
Message |
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
Hi,
I have two fields in the format hh:mm:ss. I need to subtract 1st field from 2nd field and write the result.
Eg:
I/p: FB/80
02:08:02 02:07:56
O/p: FB/80
02:08:02 02:07:56 00:00:06
Is it possible. Kindly share your thoughts on this.
Thanks
R KARTHIK. |
|
Back to top |
|
|
saiprasadh
Active User
Joined: 20 Sep 2006 Posts: 154 Location: US
|
|
|
|
I used below mentioned sort card. There might be other solution.
Code: |
//STEP01 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTIN DD *
02:08:02 02:07:56
02:10:02 02:07:56
03:08:02 02:07:56
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(55:((1,2,ZD,MUL,+3600),
ADD,(4,2,ZD,MUL,+60),ADD,7,2,ZD),LENGTH=10,M11,
65:((10,2,ZD,MUL,+3600),
ADD,(13,2,ZD,MUL,+60),ADD,16,2,ZD),LENGTH=10,M11,
75:55,10,ZD,SUB,65,10,ZD,LENGTH=10,M11,
19:75,10,ZD,DIV,+3600,LENGTH=02,M11,
21:C':',
22:(75,10,ZD,SUB,(19,2,ZD,MUL,+3600)),DIV,+60,
LENGTH=02,M11,
24:C':',
25:75,10,ZD,SUB,
((19,2,ZD,MUL,+3600),ADD,(22,2,ZD,MUL,+60)),
LENGTH=02,M11,55:30X))
/*
|
Output:
Code: |
02:08:02 02:07:56 00:00:06
02:10:02 02:07:56 00:02:06
03:08:02 02:07:56 01:00:06 |
|
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
use the following DFSORT JCL which will give you the desired results
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
02:08:02 02:07:56
02:10:02 02:07:56
03:08:02 02:07:56
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=80,IFTHEN=(WHEN=INIT,
OVERLAY=(81:(01,2,ZD,MUL,+3600,ADD, $ (HH * 3600 +
04,2,ZD,MUL,+0060,ADD, $ MM * 0060 +
07,2,ZD),SUB, $ SS) -
(10,2,ZD,MUL,+3600,ADD, $ (HH * 3600 +
13,2,ZD,MUL,+0060,ADD, $ MM * 0060 +
16,2,ZD), $ SS)
M11,LENGTH=8,
20:81,8,ZD,DIV,+3600,EDIT=(TT),C':',
(81,8,ZD,MOD,+3600),DIV,+60,EDIT=(TT),C':',
((81,8,ZD,MOD,+3600),MOD,+60),EDIT=(TT)))
//* |
|
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
will the 1st field always be greater than the 2nd field ?
will the 2 fields always be within the same day ?
Gerry |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
gcicchet wrote: |
Hi,
will the 1st field always be greater than the 2nd field ? |
gcicchet,
We are taking the absolute value , so it does not matter which field is greater unless OP needs a sign to show the negative difference.
gcicchet wrote: |
will the 2 fields always be within the same day ?
|
Unless there is a date involved with these times, it doesn't matter. |
|
Back to top |
|
|
karthikr44
Active User
Joined: 25 Aug 2007 Posts: 235 Location: Chennai
|
|
|
|
Hi Skolusu,
Your code is working perfectly as expected.
And the 1st field will be always greater than 2nd field.
Thanks
R KARTHIK |
|
Back to top |
|
|
|
|