Could anybody assist me in the following requirement :
Date & time deails from a JOB.
1.How to get a Date and time details from latest run of a Job.
2.And, after getting them is there a possibility to subtract or add a few seconds to the Start-time and End-time time and give it as an Input to a downstream 2nd Job.
To give you more clarity...let me explain it with an example
Latest run of 1st Job : VKODSD1
JOBNAME JOB # CCODE START DATE TIME END DATE TIME
VKODSD1 0006765 RC=0004 FRI 31 MAR 2006.090 00:05 FRI 31 MAR 2006.090 01:00
Now, after it had finished we manually correct the JOBSYSIN as below
FROM DATE(2006-03-31) TIME(00.03.00.000001)
TO DATE(2006-03-31) TIME(01.02.00.000000)
i.e., we subtract 2 secs from the start-time and add 2 secs to the End-time and submit the second Job VKODSD2, which reads in the above updated JOBSYSIN and runs.
The Business is to collect the logs of various Databases.
Today, we do the above process Manually and requirement now is to Automate the above process.
Do kindly pour in your valuable thought to accomplish the above.
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
Sathya,
I?m sure there are exit points in MVS that can be tied into at job start and end times, but I would not want to be doing this.
How many JOBS are you considering doing this for? If you are doing this by hand, I guess there are not very many of them.
Could you add a step at the beginning of the job and one at the end of the job that would write the job start and end times to a log that you could use? It could use the PARM to determine the record format and if it should add/subtract 2 seconds.
i.e.
Code:
//VKODSD1 JOB ...
//* LOG THE JOB START TIME ? 2 SEC
//LOGSTIME EXEC PGM=LOGTIME,PARM=?FROM?
//LOGFILE DD DSN=YOUR.LOG.FILE.VKODSD1,DISP=SHR
:
EXISTING JCL
:
//* LOG THE JOB END TIME + 2 SEC
//LOGETIME EXEC PGM=LOGTIME,PARM=?TO?
//LOGFILE DD DSN=YOUR.LOG.FILE.VKODSD1,DISP=SHR
//
Yes, as you guessed I do have only view jobsin my hand and it was not a problem in adding the steps. But, when I did so and scanned with a "JJ", it gave me the error:
MEMBER 'LOGTIME' WAS NOT FOUND.
'VKODSD1 LOGSTIME': STEP WOULD ABEND,
CODE 'S806'.
Where does this "LOGTIME" PGM reside, should I need to add the relevent PDS dataset in my JCLLIB step.
(or)
Is this PGM part of any special software like "BMC"or something else
Please Advise !
To give an overall idea abt our system, we use CA-7 for Scheduling, $AVRS (similar to JHS) for Spool Display, other that we have File-Aid, BMC tools.
Would Appreciate if you could have some thought on this.
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
Sathya,
My appologies for not being more clear. It was intended the 'LOGTIME' would be something you would write for this purpose.
I spent a short time and came up with the following code that I believe will suit your purpose. JCL to run tests follows. Note that this was not designed to add/subtract large time periods, as it does not take into consideration multiple leap years. Please test this to make sure it performs as expected. I have tested some critical date/times, and they function as I expect, but you must do additional testing.
Code:
ID DIVISION.
PROGRAM-ID. LOGTIME.
AUTHOR. DAVIDATK.
DATE-WRITTEN. APRIL 2006.
DATE-COMPILED.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT LOG-FILE ASSIGN TO LOGFILE.
DATA DIVISION.
FILE SECTION.
FD LOG-FILE
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS.
01 LOG-REC PIC X(80).
WORKING-STORAGE SECTION.
01 LOG-RECORD PIC X(80).
01 LY PIC S9(9) COMP-3.
01 LY-R PIC S9(9) COMP-3.
01 SUB PIC S9(3) COMP-3.
01 WS-DATE-TIME PIC 9(9) COMP.
01 WS-DATE.
05 YY PIC 99.
05 MM PIC 99.
05 DD PIC 99.
01 WS-DATE-ORIG.
05 YY PIC 99.
05 MM PIC 99.
05 DD PIC 99.
01 WS-TIME.
05 HH PIC 99.
05 MM PIC 99.
05 SS PIC 99.
01 WS-TIME-ORIG.
05 HH PIC 99.
05 MM PIC 99.
05 SS PIC 99.
01 MM-DD-TBL.
05 MM-01 PIC 9(3) COMP-3 VALUE 0.
05 MM-02 PIC 9(3) COMP-3 VALUE 31.
05 MM-03 PIC 9(3) COMP-3 VALUE 59.
05 MM-04 PIC 9(3) COMP-3 VALUE 90.
05 MM-05 PIC 9(3) COMP-3 VALUE 120.
05 MM-06 PIC 9(3) COMP-3 VALUE 151.
05 MM-07 PIC 9(3) COMP-3 VALUE 181.
05 MM-08 PIC 9(3) COMP-3 VALUE 212.
05 MM-09 PIC 9(3) COMP-3 VALUE 243.
05 MM-10 PIC 9(3) COMP-3 VALUE 273.
05 MM-11 PIC 9(3) COMP-3 VALUE 304.
05 MM-12 PIC 9(3) COMP-3 VALUE 334.
01 MM-DD-TBL-R REDEFINES MM-DD-TBL.
05 MM-DAYS OCCURS 12 TIMES
PIC 9(3) COMP-3.
01 LOG-DETAIL PIC X(80) VALUE
'DATE(20YY-MM-DD) TIME(HH.MM.SS.000000)'.
* 12345678901234567890123456789012345678
* 0 1 2 3
IF PARM-LEN = 20
THEN
MOVE PARM-DATE TO WS-DATE
MOVE PARM-TIME TO WS-TIME
ELSE
ACCEPT WS-DATE FROM DATE
ACCEPT WS-TIME FROM TIME
END-IF.
MOVE WS-DATE TO WS-DATE-ORIG.
MOVE WS-TIME TO WS-TIME-ORIG.
DIVIDE YY OF WS-DATE BY 4 GIVING LY REMAINDER LY-R.
IF LY-R = 0
THEN
ADD +1 TO MM-03
MM-04
MM-05
MM-06
MM-07
MM-08
MM-09
MM-10
MM-11
MM-12
END-IF.
COMPUTE WS-DATE-TIME = YY OF WS-DATE * 365
+ MM-DAYS(MM OF WS-DATE)
+ DD OF WS-DATE.
COMPUTE WS-DATE-TIME = (WS-DATE-TIME * (24 * 60 * 60))
+ (HH OF WS-TIME * (60 * 60))
+ (MM OF WS-TIME * 60)
+ SS OF WS-TIME.
IF PARM-TYPE(1:4) = 'FROM'
THEN
SUBTRACT 2 FROM WS-DATE-TIME
ELSE
ADD 2 TO WS-DATE-TIME
END-IF.
DIVIDE WS-DATE-TIME BY 60 GIVING WS-DATE-TIME
REMAINDER SS OF WS-TIME.
DIVIDE WS-DATE-TIME BY 60 GIVING WS-DATE-TIME
REMAINDER MM OF WS-TIME.
DIVIDE WS-DATE-TIME BY 24 GIVING WS-DATE-TIME
REMAINDER HH OF WS-TIME.
DIVIDE WS-DATE-TIME BY 365 GIVING YY OF WS-DATE
REMAINDER WS-DATE-TIME.
IF WS-DATE-TIME = 0
THEN
SUBTRACT 1 FROM YY OF WS-DATE
ADD 365 TO WS-DATE-TIME
END-IF.
PERFORM
VARYING SUB FROM 12 BY -1
UNTIL MM-DAYS(SUB) < WS-DATE-TIME
END-PERFORM.
MOVE SUB TO MM OF WS-DATE.
SUBTRACT MM-DAYS(SUB) FROM WS-DATE-TIME
GIVING DD OF WS-DATE.
MOVE YY OF WS-DATE TO LOG-DETAIL(8:2).
MOVE MM OF WS-DATE TO LOG-DETAIL(11:2).
MOVE DD OF WS-DATE TO LOG-DETAIL(14:2).
MOVE HH OF WS-TIME TO LOG-DETAIL(23:2).
MOVE MM OF WS-TIME TO LOG-DETAIL(26:2).
MOVE SS OF WS-TIME TO LOG-DETAIL(29:2).
IF PARM-TYPE(1:4) = 'FROM'
THEN
MOVE 'FROM' TO LOG-RECORD
MOVE LOG-DETAIL TO LOG-RECORD(6:74)
ELSE
MOVE 'TO' TO LOG-RECORD
MOVE LOG-DETAIL TO LOG-RECORD(4:76)
END-IF.
OPEN OUTPUT LOG-FILE.
WRITE LOG-REC FROM LOG-RECORD.
CLOSE LOG-FILE.
GOBACK.
Please not that the second time you use the file you must reference it as 'DISP=MOD'
Also if you remove the 'SET DATE, and SET TIME' it will take the system data/time. You can use the 'SET DATE/TIME' for testing/validation.