Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Reg: Subtract time field using DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Reg: Subtract time field using DFSORT
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    Post subject:
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    Post subject:
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: 1703
Location: Australia

PostPosted: Thu May 03, 2012 4:35 am    Post subject:
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    Post subject:
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    Post subject: Reply to: Reg: Subtract time field using DFSORT
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DSNACCOX (can it be run on 1 db/ts, t... SRICOBSAS DB2 3 Sat May 06, 2017 12:59 am
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts Application not run by time HH:MM tri... jzhardy IBM Tools 1 Sun Apr 09, 2017 3:22 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us