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
 

 

DFSORT to subtract two timestamp fields in a file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
madishpa

New User


Joined: 18 May 2007
Posts: 27
Location: Hyderabad

PostPosted: Thu Sep 27, 2012 5:38 pm    Post subject: DFSORT to subtract two timestamp fields in a file
Reply with quote

Hello All,

Could you please help with the below requirement.

Input file : (LRECL - 80 , RECFM - FB)

Code:
xxxxxxxx201209251709201209251830
yyyyyyyy201209251820201209260100


First 8 bytes in input file is jobname (position 1 - 8)
Next 12 bytes is actual start time of the job in format (YYYYMMDDHHMM) (position 9 - 20)
Next 12 bytes is actual end time of the job in format (YYYYMMDDHHMM)
(position 21-32)

Output file: (LRECL - 30 , RECFM - FB)

Code:
XXXXXXXX201209250121
yyyyyyyy201209250640

Output file includes 2 fields

1. first field is jobname - (position 1- 8)
2. second field is actual run time ( actual end time - actual start time)


Thanks
Madishpa

Code'd and number of "y"s corrected.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Thu Sep 27, 2012 5:48 pm    Post subject: Reply to: DFSORT to subtract two timestamp fields in a file
Reply with quote

You could have a look at this one.

EDIT.

I assume that the "date" part you want on the output is that of the end of the run? Rather than the date part being subtracted? But that you want the difference in hours and minutes (not bothered about seconds?) even if start on one day, end on a different one?
Back to top
View user's profile Send private message
madishpa

New User


Joined: 18 May 2007
Posts: 27
Location: Hyderabad

PostPosted: Thu Sep 27, 2012 6:11 pm    Post subject: Reply to: DFSORT to subtract two timestamp fields in a file
Reply with quote

I would convert hours and miutes in to seconds before subtraction.
If the start and end dates falls on the same day, this works.

could you please help me how to handle in the case where the start and end dates falls on the different day.

Thanks
Madishpa
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Sep 27, 2012 6:31 pm    Post subject:
Reply with quote

Madishpa,

I see you spent many nanoseconds going over Bill's link.

DATEDIFF is what does the trick.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Thu Sep 27, 2012 6:31 pm    Post subject: Reply to: DFSORT to subtract two timestamp fields in a file
Reply with quote

Did you look at the link provided?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Sep 27, 2012 6:37 pm    Post subject: Re: Reply to: DFSORT to subtract two timestamp fields in a f
Reply with quote

Bill Woodger wrote:
Did you look at the link provided?


why? he wants his customized solution,
and does not want to wade thru any extraneous verbiage.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Thu Sep 27, 2012 9:02 pm    Post subject: Reply to: DFSORT to subtract two timestamp fields in a file
Reply with quote

madishpa,

If you are just waiting around for an answer, you'll need to at least provide the output from this step, so we can see what level of the product you have.

Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN DD *
RECORD
/*
//SORTOUT DD DUMMY
//SYSIN   DD   *
  OPTION COPY
/*
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Fri Sep 28, 2012 1:34 am    Post subject: Re: Reply to: DFSORT to subtract two timestamp fields in a f
Reply with quote

dbzTHEdinosauer wrote:
Bill Woodger wrote:
Did you look at the link provided?


why? he wants his customized solution,
and does not want to wade thru any extraneous verbiage.


Add a private message too. icon_sad.gif

madishpa wrote:
I would convert hours and miutes in to seconds before subtraction. If the start and end dates falls on the same day, this works.


Your sample data has only HHMM for time , why would you convert the time into seconds format? You just need to convert it into minutes.

Assuming that the date-time at position 21 is always greater or equal to the date-time at position 9 , the following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
XXXXXXXX201209251709201209251830                         
YYYYYYYY201209251820201209260100                         
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                       
  INREC IFOUTLEN=30,IFTHEN=(WHEN=INIT,                   
  OVERLAY=(40:(17,2,ZD,MUL,+60),ADD,19,2,ZD,M11,LENGTH=8,
           50:(29,2,ZD,MUL,+60),ADD,31,2,ZD,M11,LENGTH=8,
           60:21,8,Y4T,DATEDIFF,9,8,Y4T,                 
           70:(60,8,SFF,MUL,+1440),ADD,                 
               50,8,ZD,SUB,40,8,ZD,M11,LENGTH=8,         
           80:70,8,ZD,DIV,+60,EDIT=(TT),                 
              70,8,ZD,MOD,+60,EDIT=(TT),                 
           17:80,4,10X))                                 
                                                         
//*
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7234

PostPosted: Sat Sep 29, 2012 6:04 am    Post subject: Reply to: DFSORT to subtract two timestamp fields in a file
Reply with quote

madishpa,

Please do not PM anyone for assistance. If this happens again, there will be a Warning for you.

I notice that you have not even thanked Kolusu for the solution provided.

You did not use the Code tags, and made a mistake with your sample data which you'd have spotted easily if you had use the Code tags and Preview. This was corrected for you.

You mis-described your requirement.

You have been here long enough to know that all of the above you should have been done differently.

Next time, please, do not repeat any of these mistakes.
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 Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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