Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Accessing Job ID?

818 views
Skip to first unread message

Paul Gilmartin

unread,
Feb 27, 2012, 11:34:12 AM2/27/12
to
A job step wants to use the Rexx SDSF interface to
read SYSOUT from a previous step.

Question: How can the job get its own job ID (e.g. JOB12345)?
SYSVARS? MVSVARS? Other? (I'd prefer not to chase control
blocks.)

Thanks,
gil

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX

Don Imbriale

unread,
Feb 27, 2012, 12:06:33 PM2/27/12
to
TFM [always a good place to start] says MVSVAR('SYMDEF',JOBNAME )

- Don Imbriale

On Mon, Feb 27, 2012 at 11:32 AM, Paul Gilmartin <PaulGB...@aim.com>wrote:

> A job step wants to use the Rexx SDSF interface to
> read SYSOUT from a previous step.
>
> Question: How can the job get its own job ID (e.g. JOB12345)?
> SYSVARS? MVSVARS? Other? (I'd prefer not to chase control
> blocks.)
>
>

Binyamin Dissen

unread,
Feb 27, 2012, 12:23:36 PM2/27/12
to
JOBID ^= JOBNAME

On Mon, 27 Feb 2012 12:00:06 -0500 Don Imbriale <don.im...@GMAIL.COM>
wrote:

:>TFM [always a good place to start] says MVSVAR('SYMDEF',JOBNAME )
:>
:>- Don Imbriale
:>
:>On Mon, Feb 27, 2012 at 11:32 AM, Paul Gilmartin <PaulGB...@aim.com>wrote:
:>
:>> A job step wants to use the Rexx SDSF interface to
:>> read SYSOUT from a previous step.
:>>
:>> Question: How can the job get its own job ID (e.g. JOB12345)?
:>> SYSVARS? MVSVARS? Other? (I'd prefer not to chase control
:>> blocks.)

--
Binyamin Dissen <bdi...@dissensoftware.com>
http://www.dissensoftware.com

Should you use the mailblocks package and expect a response from me,
you should preauthorize the dissensoftware.com domain.

I very rarely bother responding to challenge/response systems,
especially those from irresponsible companies.

Roberto Halais

unread,
Feb 27, 2012, 1:00:41 PM2/27/12
to
JOBID and JOBNAME

/* REXX */
/* GET JOBID OF EXECUTING TASK */
TCB = STORAGE(21C,4)
JSCB = STORAGE(D2X(C2D(TCB)+180),4)
SSIB = STORAGE(D2X(C2D(JSCB)+316),4)
JOBNUM = STORAGE(D2X(C2D(SSIB)+12),8)
SAY MVSVAR('SYMDEF',JOBNAME) JOBNUM
EXIT 0
--
"Those who can make you believe religious absurdities, can make you commit
atrocities." Voltaire

The philosopher has never killed any priests, whereas the priest has
killed a great many philosophers. Denis Diderot

"Men will never be free until the last king is strangled with the entrails
of the last priest." Denis Diderot

Lizette Koehler

unread,
Feb 27, 2012, 1:11:59 PM2/27/12
to
>
>A job step wants to use the Rexx SDSF interface to
>read SYSOUT from a previous step.
>
>Question: How can the job get its own job ID (e.g. JOB12345)?
>SYSVARS? MVSVARS? Other? (I'd prefer not to chase control
>blocks.)
>
>Thanks,
>gil
>
See if the TSO STATUS command could help.

Lizette

Rob Zenuk

unread,
Feb 27, 2012, 3:22:54 PM2/27/12
to
Never thought about that... I have always used the control block
technique...

/* rexx - JOBID */
tcb = storage(21c,4)
jscb = storage(d2x(c2d(tcb)+180),4)
ssib = storage(d2x(c2d(jscb)+316),4)
jobnum = storage(d2x(c2d(ssib)+12),8)
say mvsvar('SYMDEF',JOBNAME) jobnum

Here is a quick and dirty STATUS approach...

/* rexx - JOBNUM */
x = outtrap('out.')
"STATUS ("mvsvar('SYMDEF','JOBNAME')")"
x = outtrap('off')
do i=1 to out.0
parse var out.i . '(' jobnum ')' status
if status = 'EXECUTING' then leave
end
say jobnum


Rob

Paul Gilmartin

unread,
Feb 27, 2012, 6:53:05 PM2/27/12
to
On 2012-02-27 09:42, Adrian Stern wrote:
> I hear you, but this snippet does what you want:
> <snip it>
>
Well, almost. Rexx tells me that "Internal" is an invalid sub-keyword.
You and I must be using different releases of Rexx. I can fix that, but
then:

$ cat bin/foojobid
13 *-* say '/'Get_Job_Info()'/'
16 *-* Get_Job_Info:
*-* Procedure /* Internal */
17 *-* TCB = PTR(540) /* Location
of TCB */
28 *-* PTR:
*-* trace N
>>> "8284792"
18 *-* TIOT = PTR(TCB+12) /* Location
of TIOT */
28 *-* PTR:
*-* trace N
>>> "8187856"
19 *-* JNAM = STG(TIOT,8) /* JOBNAME
*/
29 *-* STG:
*-* trace N
>>> "user "
20 *-* SNAM = STG(TIOT+8,8) /* STEP NAME
*/
29 *-* STG:
*-* trace N
>>> "STEP1 "
21 *-* PSNAM = STG(TIOT+16,8) /* PROC STEP
NAME */
29 *-* STG:
*-* trace N
>>> " "
22 *-* JSCB = PTR(TCB+180) /* Jes
control block */
28 *-* PTR:
*-* trace N
>>> "8228244"
23 *-* PNAM = STG(JSCB+360,8) /* Program
name */
29 *-* STG:
*-* trace N
>>> "BPXPRECP"
24 *-* SSIB = PTR(JSCB+316) /* Location
of SSIB */
28 *-* PTR:
*-* trace N
>>> "8236768"
25 *-* JNUM = STG(SSIB+12,8) /* JOB NUMBER
*/
29 *-* STG:
*-* trace N
>>> "????????"
26 *-* say c2x( JNUM )
>>> "0000000000000000"
0000000000000000
27 *-* Return JNAM JNUM SNAM PNAM PSNAM /* Send back
info */
>>> "user ???????? STEP1 BPXPRECP "
>>> "/user ???????? STEP1 BPXPRECP /"
/user """""""" STEP1 BPXPRECP /
14 *-* exit( 0 )
>>> "0"

JNUM comes out binary zeros. Ugh!

Mickey

unread,
Feb 27, 2012, 8:15:35 PM2/27/12
to
Get_Job_Info: /* Procedure Internal */
TCB = PTR(540) /* Location of TCB */
TIOT = PTR(TCB+12) /* Location of TIOT */
JNAM = STG(TIOT,8) /* JOBNAME */
SNAM = STG(TIOT+8,8) /* STEP NAME */
PSNAM = STG(TIOT+16,8) /* PROC STEP NAME */
JESCB = PTR(TCB+180) /* Jes control block */
PNAM = STG(JESCB+360,8) /* Program name */
SSIB = PTR(JESCB+316) /* Location of SSIB */
JNUM = STG(SSIB+12,8) /* JOB NUMBER */
Return JNAM JNUM SNAM PNAM /* Send back info */
PTR: Return C2D(STORAGE(D2X(ARG(1)),4)) /* Function Internal */
STG: Return STORAGE(D2X(ARG(1)),ARG(2)) /* Function Internal */



--------------------------------------------------
From: "Rob Zenuk" <robz...@AOL.COM>
Sent: Monday, February 27, 2012 3:21 PM
To: <TSO-...@VM.MARIST.EDU>
Subject: Re: [TSO-REXX] Accessing Job ID?

Paul Gilmartin

unread,
Feb 28, 2012, 4:39:38 AM2/28/12
to
On Feb 28, 2012, at 01:51, Adrian Stern wrote:

> I don't have access to a mainframe right now and that exec hasn't been used
> for over 10 years, but how are you running it?
>
Under a Unix System Services shell. I know some things
behave differently under TSO.

> -----Original Message-----
> From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of
> Paul Gilmartin
> Sent: den 28 februari 2012 00:51
> To: TSO-...@VM.MARIST.EDU
> Subject: Re: [TSO-REXX] Accessing Job ID?
>
-- gil

Paul Gilmartin

unread,
Feb 28, 2012, 7:40:50 AM2/28/12
to
On Feb 28, 2012, at 03:56, Adrian Stern wrote:

> That's what I suspected - try it in an mvs task - tso or a batch job - it
> should work.
>
Which doesn't really solve my problem. I'm looking
for something that works in all environments:

o TSO

o IRXJCL

o UNIX shell

o Started task

o Rexx invoked by a program via API

Others?

The fact that you can demonstrate one case where it
works doesn't refute its failure in other cases. The
JSAB technique someone else suggested seems more general

Thanks,

Thomas Berg

unread,
Feb 28, 2012, 9:21:45 AM2/28/12
to
"Internal" is not per syntax accordingly to manual z/OS V1R12.0 TSO/E REXX Reference.
And I haven't heard of it either. Maybe it's from a flavor of rexx outside of MVS.

BTW, the rexx below gives: S000TBE TSU 29059 KAT30 KAT30

/* REXX */

tcb = Stor(D2x(540,8),4)
tiot = Stor(tcb 12,4)
jobname = Stor(tiot ,8)
stepname = Stor(tiot 8,8)
procstep = Stor(tiot 16,8)
jscb = Stor(tcb 180,4)
ssib = Stor(jscb 316,4)
jobtype = Stor(ssib 12,3)
jobnumber = Stor(ssib 15,5)

Say jobname jobtype jobnumber stepname procstep

Exit 0

STOR:
Parse Arg a, l, d, .

Numeric digits 10
If Length(Word(a,1)) > 4 Then Do
Parse Var a a di a2 .
a = X2d(a)
a2 = X2d(a2)
End
Else Do
Parse Var a a 5 di a2
a = C2d(a)
a2 = C2d(a2)
End

Return Storage(D2x(a + Word(di 0,1) + Word(a2 0,1),8),Word(l 4,1),d)


 
Regards,
Thomas Berg
_________________________________________
Thomas Berg   Specialist   A M   SWEDBANK



> -----Ursprungligt meddelande-----
> Från: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] För Adrian
> Stern
> Skickat: den 28 februari 2012 11:56
> Till: TSO-...@VM.MARIST.EDU
> Ämne: Re: [TSO-REXX] Accessing Job ID?
>
> That's what I suspected - try it in an mvs task - tso or a batch job - it
> should work.
>

Jeff Byrum

unread,
Feb 28, 2012, 10:10:11 AM2/28/12
to
I know I've done something like what you are describing using the SDSF interface, but can't seem to find the code.

However, here's a clue. If you run the following:

//MYJOB JOB 0,TST.SDSF,MSGCLASS=A,CLASS=A
//SDSF EXEC PGM=SDSF
//ISFOUT DD SYSOUT=*
//ISFIN DD *
PREFIX MYJOB
DA

You will see that the output contains the jobname and jobid for this execution of MYJOB itself. Of course you have to provide the actual jobname in the input, which may not satisfy your requirements. Maybe this will give you an idea of how to proceed though.

As I recall, I put the "ISFIN" input commands on the stack, allocated an ISFOUT dataset, and invoked SDSF with ADDRESS LINKMVS, and then scanned the output for the JOBID. Note that there are multiple SDSF screens in the output, and the actual entry you are looking for is on the last one, so you have to scroll down almost all the way to the bottom to find it. There are also parameters you can supply to control width and depth of pages.

I remember that the SDSF interface, while quite powerful, produced output that was not exactly what I was expecting, and there are a number of non-intuitive (to me!) control commands starting with "++", and a "?" command that rotates among the various alternative versions of the panel you are viewing (ST, DA, H) so I spent a lot of time running batch jobs like the above to get the exact output I wanted, and in order to understand how to scan it.

BTW, the "?" command works online under SDSF to change views of the current panel.

Sorry I can't provide any actual code. Hope this helps.


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of Paul Gilmartin

Ward Able, Grant

unread,
Feb 28, 2012, 10:59:35 AM2/28/12
to
Gil - isn't this going to be a case of having a procedure that can recognise if it is in USS (or other environments) or not?

You said that JNUM comes out as binary zeroes. But then is JOB NUMBER valid in USS? Would a process ID not be more suitable? I tried this as a batch job & found that the PSNAM was blanks when I ran it. Not surprisingly, as I did not execute a procedure. So I added a line of code to change a blank PSNAM to "N/A".



Sorry if that sounds too simple, but I am not entirely sure you will be able to get all of the environments to return you "good" data, unless you add code for specific environments (e.g. "if syscalls('ON')>3" ).



If I am mistaken about that, then please educate me!



Regards - Grant.

Telephone Internal: x1496 London

Telephone External: +44 (0)207 650 1496





-----Original Message-----

From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of Paul Gilmartin

Sent: 28 February 2012 12:39

To: TSO-...@VM.MARIST.EDU

Subject: Re: [TSO-REXX] Accessing Job ID?



<BR>_____________________________________________________________

<FONT size=2><BR>

DTCC DISCLAIMER: This email and any files transmitted with it are

confidential and intended solely for the use of the individual or

entity to whom they are addressed. If you have received this email

in error, please notify us immediately and delete the email and any

attachments from your system. The recipient should check this email

and any attachments for the presence of viruses. The company

accepts no liability for any damage caused by any virus transmitted

by this email.</FONT>

Rob Zenuk

unread,
Feb 28, 2012, 12:43:59 PM2/28/12
to
I believe your original email said:

>>A job step wants to use the Rexx SDSF interface to read SYSOUT from a
>>previous step.
>>
>>Question: How can the job get its own job ID (e.g. JOB12345)?
>>SYSVARS? MVSVARS? Other? (I'd prefer not to chase control
>>blocks.)

This strongly suggests batch... Whether you are using the USS API's or not.
If your requirements were different, you should have stated so.

Notwithstanding, here is an example of using the SDSF/REXX API to read the
JOBLOG. The same logic can be used to select the job with a '?' to split
out the SYSOUT's then select the desired SYSOUT and read that. Sample
pseudo-logic below.

This is a Return Code checker so a job can check its own return codes in a
step towards the end of the job and provide a summary report and/or do
something. This is useful in jobs with a large number of steps where
non-zero return codes are expected (like mass recompiles/reassembles), but
it is a reasonable (and small) example of using the SDSF/REXX interface to
navigate SYSOUT's. I have never tried to run this under the Shell...

If you want to try this EXEC for the purpose it was designed for, it depends
on return codes existing in the JOBLOG (like the sample MVS exit provides).
However, the eyecatchers for this version are LOCAL eyecatchers... You will
need to find your own eyecatchers to help position the job in the JOBLOG.

/*********************************************************************/
/* REXX */
/*********************************************************************/
/* Purpose: Return Code Checker */
/*-------------------------------------------------------------------*/
/* Syntax: RCCHECK */
/*-------------------------------------------------------------------*/
/* Parms: N/A - N/A */
/* */
/*********************************************************************/
/* Change Log */
/* */
/* Author Date Reason */
/* -------- --------- ----------------------------------------- */
/* R. Zenuk Aug 2010 Initial Creation */
/* */
/*********************************************************************/
/* Set Exit Code, the number of bad steps and the current jobname */
/*********************************************************************/
EXITRC = 0
stepcount = 0
jobname = mvsvar('SYMDEF','JOBNAME')
/*********************************************************************/
/* Invoke SDSF DA */
/*********************************************************************/
if isfcalls('ON') <> 0 then exit 99
address SDSF "ISFEXEC DA"
call isferror 'ISFEXEC'
/*********************************************************************/
/* Find the current jobname */
/*********************************************************************/
do i=1 to isfrows
if jname.i = jobname then
do
/*********************************************************************/
/* Write the report heading */
/*********************************************************************/
say
say 'Steps with non-zero return codes in job' jobname jobid.i
say
/*********************************************************************/
/* Select the jobname and allocate all the output sysout datasets */
/*********************************************************************/
address SDSF "ISFACT DA TOKEN('"token.i"') PARM(NP SA)"
call isferror 'ISFACT'
/*********************************************************************/
/* Read the JOBLOG */
/*********************************************************************/
address TSO "EXECIO * DISKR" isfddname.1 "(STEM JOBLOG. FINIS"
/*********************************************************************/
/* Parse out the STEP and RC */
/*********************************************************************/
do l=1 to joblog.0
steploc = pos('#STEPNAME',joblog.l)
if steploc <> 0 then
steppos = steploc + 1
rcloc = pos(' RC ',joblog.l)
if rcloc <> 0 then
rcpos = rcloc + 1
/*********************************************************************/
/* Find the lines with the step results */
/*********************************************************************/
if left(word(joblog.l,3),1) = '#' &,
word(joblog.l,3) <> '#CHARLES' &,
word(joblog.l,3) <> '#STEPNAME' then
do
/*********************************************************************/
/* Find the non-zero steps */
/*********************************************************************/
if substr(joblog.l,rcpos,2) <> '00' then
do
/*********************************************************************/
/* Log and count */
/*********************************************************************/
say substr(joblog.l,steppos,8),
substr(joblog.l,rcpos,2)
stepcount = stepcount + 1
EXITRC = 20
end
end
end
end
end
/*********************************************************************/
/* Summarize the bad steps */
/*********************************************************************/
say
say stepcount 'steps with non-zero return codes'
say
call isfcalls 'OFF'
exit EXITRC
/*********************************************************************/
/* SDSF error conditions */
/*********************************************************************/
isferror: arg sdfscall
select
/*********************************************************************/
/* Ignorable conditions */
/*********************************************************************/
when isfmsg = '' then return
when isfmsg = 'DATA SET ALLOCATED' then return
/*********************************************************************/
/* Real errors - always RC=16 */
/*********************************************************************/
otherwise
do
say isfmsg
say
do e=1 to isfmsg2.0
say sdsfcall right(e,2)':' isfmsg2.e
end
exit 16
end
end

To select a specific SYSOUT (starting from SDSF DA)...

Address SDSF "ISFEXEC DA"
Loop and find yourself by mvsvar('SYMDEF','JOBNAME')
Select the job and displays its SYSOUT's
Address SDSF "ISFACT DA TOKEN('"token.r"') PARM(NP ?) (PREFIX $"
Loop and find you desired SYSOUT
Select the SYSOUT
Address SDSF "ISFACT DA TOKEN('"$token.s"') PARM(NP SA)"
EXECIO the SYSOUT
Continue with normal REXX activities from there.
EndLoop
EndLoop

I use a technique like this to find all our CICS regions, select 4 of the
SYSOUT's of interest and analyze their contents for alerting and automation
purposes... Unfortunately, that EXEC is very long and has lots of site
specific logic...

Rob


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of
Paul Gilmartin
Sent: Tuesday, February 28, 2012 5:39 AM
To: TSO-...@VM.MARIST.EDU
Subject: Re: Accessing Job ID?

Chip Grantham

unread,
Feb 28, 2012, 1:35:07 PM2/28/12
to
If I understand the question correctly, I use SDSFEXT by Lionel Dyck to
pull a report from a previous job step and create a dataset which I email
etc. Pretty cool.

http://www.lbdsoftware.com/ispftools.html

Chip Grantham | Ameritas | Sr. IT Consultant | cgra...@ameritas.com
5900 O Street, Lincoln NE 68510 | p: 402-467-7382 | c: 402-429-3579 | f:
402-325-4030

*******
This message may contain confidential information intended only
for the use of the addressee(s) named above and may contain
information that is legally privileged. If you are not the
addressee, or the person responsible for delivering it to the
addressee, you are hereby notified that reading, disseminating,
distributing or copying this message is strictly prohibited. If you
have received this message by mistake, please immediately notify
us by replying to the message and delete the original message
immediately thereafter. Thank you.
*******

Fenner, Jim

unread,
Feb 28, 2012, 6:04:36 PM2/28/12
to
Hi all,
I searched rexx code saved from this list last millennium and one of the "get the job info" rexxes contained this code

PTR: Return C2D(STORAGE(D2X(ARG(1)),4)) /* Function Internal */
STG: Return STORAGE(D2X(ARG(1)),ARG(2)) /* Function Internal */

Maybe someone cleaned up the "flowerbox" style comments and so Function Internal joined the Rexx lexicon

Jim
Canberra
**********************************************************************
IMPORTANT
The information transmitted is for the use of the intended
recipient only and may contain confidential and/or legally
privileged material. Any review, re-transmission, disclosure,
dissemination or other use of, or taking of any action in
reliance upon, this information by persons or entities other
than the intended recipient is prohibited and may result in
severe penalties. If you have received this e-mail in error
please notify the Privacy Hotline of the Australian Taxation
Office, telephone 13 2869 and delete all copies of this
transmission together with any attachments.
**********************************************************************
0 new messages