IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Reg: Subtract time field using DFSORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Wed May 02, 2012 9:01 pm
Reply with quote

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
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Wed May 02, 2012 9:48 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed May 02, 2012 10:07 pm
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu May 03, 2012 4:35 am
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu May 03, 2012 5:48 am
Reply with quote

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
View user's profile Send private message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Thu May 03, 2012 10:45 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top