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

DFSORT to subtract two timestamp fields in a file


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

New User


Joined: 18 May 2007
Posts: 28
Location: Hyderabad

PostPosted: Thu Sep 27, 2012 5:38 pm
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Sep 27, 2012 5:48 pm
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: 28
Location: Hyderabad

PostPosted: Thu Sep 27, 2012 6:11 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Sep 27, 2012 6:31 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Sep 27, 2012 9:02 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Sep 29, 2012 6:04 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top