Page 1 of 2

pass timestamp from jcl to cobol

PostPosted: Wed Dec 30, 2015 12:59 am
by iaccbond
hi guys
i have a requirment where i have to pass jcl job start timestamp to cobol program (step p050) and inserted it in the output file of that program
could you please help me out

basically i need to pass timestamp (26 size) from jcl to cobol pgm.

Re: pass timestamp from jcl to cobol

PostPosted: Wed Dec 30, 2015 2:46 am
by Robert Sample
Where is the timestamp coming from?

Re: pass timestamp from jcl to cobol

PostPosted: Wed Dec 30, 2015 11:26 am
by iaccbond
we want current timestamp in the pgm ; the timestamp at which the job started.

Re: pass timestamp from jcl to cobol

PostPosted: Wed Dec 30, 2015 5:13 pm
by Akatsukami
iaccbond wrote:we want current timestamp in the pgm ; the timestamp at which the job started.

Which completely fails to answer Mr. Sample's question, viz.,
Where is the timestamp coming from?

You get it by chasing control blocks; the start date is in the job control table extension (JCTX) and the start time in the job control table (JCT) itself, which also contains a scheduler work area virtual address (SVA) to the JCTX.

The job step control block (JSCB) contains a SVA to the JCT; the task control block (TCB) contains the address of the JSCB; and the TCB is always at (decimal) address 540. Further details are in the MVS Data Areas manuals.

Although I have not verified it, the start date and time appear to be BCD; you'll need to format them into the DB2-style timestamp that you want.

Re: pass timestamp from jcl to cobol

PostPosted: Thu Dec 31, 2015 11:00 am
by iaccbond
well i did not get it ..
i just need to pass current timestamp from jcl to cobol as input.
my pgm required job start timestamp ..
any help will be helpfull.

Re: pass timestamp from jcl to cobol

PostPosted: Thu Dec 31, 2015 4:30 pm
by NicC
Why do you need the job start time? Why not the program start time? You can get the program start time by ACCEPT TIME but to get the job start time is not easy - you have to follow the steps noted by Akatsukami and you will have to do this in a program - either a stand-alone program and pass the derived time via a dataset to your cobol program or within your program itself.

Re: pass timestamp from jcl to cobol

PostPosted: Thu Dec 31, 2015 5:11 pm
by Akatsukami
iaccbond wrote:i just need to pass current timestamp from jcl to cobol as input.
my pgm required job start timestamp ..

But you see, my dear child, you cannot. When the JCL is interpreted -- which may be well before the job actually starts -- it is then frozen. As NicC says, you can easily get the program start time, but the actual job start time can only be gotten by chasing control blocks.

NicC also asks an important question: why do you need the job start time? If you can explain that, we may be able to show you a solution to your problem that does not require doing the impossible.

Re: pass timestamp from jcl to cobol

PostPosted: Thu Dec 31, 2015 5:55 pm
by prino
Akatsukami wrote:
iaccbond wrote:NicC also asks an important question: why do you need the job start time? If you can explain that, we may be able to show you a solution to your problem that does not require doing the impossible.

Dear Akatsukami-san, why don't you realize that "it is the requirement" set by Image...

Re: pass timestamp from jcl to cobol

PostPosted: Thu Dec 31, 2015 6:05 pm
by iaccbond
well guys i got and @prino u r 100% correct.
i have put below in sort card , had first step for sort , move the timestamp in a particular file and nailed it.
SORT FIELDS=COPY
OUTREC BUILD=(1:DATE5)

Re: pass timestamp from jcl to cobol

PostPosted: Thu Dec 31, 2015 6:11 pm
by Akatsukami
iaccbond wrote:well guys i got and @prino u r 100% correct.
i have put below in sort card , had first step for sort , move the timestamp in a particular file and nailed it.
SORT FIELDS=COPY
OUTREC BUILD=(1:DATE5)

See? You didn't really want the job start date and time; you wanted an easily-gotten approximation of the job start date and time. If you'd said that two days ago, we could have told you how to do it.