Discussion:
C code to get running job name
(too old to reply)
Peter Relson
2018-01-12 12:48:24 UTC
Permalink
FWIW,

If I want to get the jobname, I use ASSBJBNI (ASSBJBNS if this is a
started task).

If ASSBJBNI first byte is not x'00' then use ASSBJBNI
else use ASSBJBNS

PSAAOLD -> ASCBASSB -> ASSBxxxx.

This has been available for going on 25 years. And prior to that (and you
can still use this if you're within the scope of the running job), you
could locate the 8-byte jobname using the addresses in ASCBJBNI (when not
0) or ASCBJBNS which have been available "forever".

Getting the step name is a different matter, as that is in the TIOT.

Peter Relson
z/OS Core Technology Design


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Steve Smith
2018-01-12 16:15:54 UTC
Permalink
It took me a while to discern the difference between ASSBJBNx and
ASCBJBNx. I initially thought you were repeating yourself :-).

Yet another way to skin this cat is to go from ASSBJSAB -> JSABJBNM.
The JSAB also has the JOB ID (among other things, of course).

sas
Post by Peter Relson
FWIW,
If I want to get the jobname, I use ASSBJBNI (ASSBJBNS if this is a
started task).
If ASSBJBNI first byte is not x'00' then use ASSBJBNI
else use ASSBJBNS
PSAAOLD -> ASCBASSB -> ASSBxxxx.
This has been available for going on 25 years. And prior to that (and you
can still use this if you're within the scope of the running job), you
could locate the 8-byte jobname using the addresses in ASCBJBNI (when not
0) or ASCBJBNS which have been available "forever".
Getting the step name is a different matter, as that is in the TIOT.
Peter Relson
z/OS Core Technology Design
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
--
sas

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Ed Jaffe
2018-01-12 20:19:26 UTC
Permalink
Post by Peter Relson
If ASSBJBNI first byte is not x'00' then use ASSBJBNI
else use ASSBJBNS
This is the first I've heard of the "first byte test" trick. All of our
code does this (or something very similar):

|   LLGT  R14,PSAAOLD
|   LLGT  R14,ASCBJBNI
|   IF LTGR,R14,R14,Z
|     LLGT  R14,ASCBJBNS
|   ENDIF ,
--
Phoenix Software International
Edward E. Jaffe
831 Parkview Drive North
El Segundo, CA 90245
http://www.phoenixsoftware.com/

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Steve Smith
2018-01-12 20:36:37 UTC
Permalink
Gotcha! There's a subtle difference between BUTTBJBNI and ASCBJNI.
The former is defined as a 'D' (bogusly), and contains the actual
jobname. The latter points to the jobname, possibly to the former,
but who knows. You can't do a 1-byte test on that address, only on
the character field.

sas
Post by Peter Relson
If ASSBJBNI first byte is not x'00' then use ASSBJBNI
else use ASSBJBNS
This is the first I've heard of the "first byte test" trick. All of our code
| LLGT R14,PSAAOLD
| LLGT R14,ASCBJBNI
| IF LTGR,R14,R14,Z
| LLGT R14,ASCBJBNS
| ENDIF ,
--
Phoenix Software International
Edward E. Jaffe
831 Parkview Drive North
El Segundo, CA 90245
http://www.phoenixsoftware.com/
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
--
sas

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Gord Tomlin
2018-01-12 21:36:20 UTC
Permalink
Post by Steve Smith
Gotcha! There's a subtle difference between BUTTBJBNI and ASCBJNI.
The former is defined as a 'D' (bogusly), and contains the actual
jobname. The latter points to the jobname, possibly to the former,
but who knows. You can't do a 1-byte test on that address, only on
the character field.
Nice auto-correct on ASSBJBNI!

ASCBJBNI and ASCBJBNS do not point to ASSBJBNI and ASSBJBNS
respectively. The pointers in the ASCB point to field CHNAME in CSCX.
Anyone with AMODE 24 code might prefer the ASCB pointers, since the CSCX
is below the line and the ASSB is above the line.

We pick up the jobname from JSABJBNM. The jobname is seldom the only
item we want, and the JSAB is a nice place to pick up several items of
interest to us. Gotta love one-stop shopping. Prior to the existence of
the JSAB, we used to use ASCBJBNI/ASCBJBNS.

--

Regards, Gord Tomlin
Action Software International
(a division of Mazda Computer Corporation)
Tel: (905) 470-7113, Fax: (905) 470-6507
Support: https://actionsoftware.com/support/

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
John McKown
2018-01-13 15:32:17 UTC
Permalink
​Just for fun, I wrote the C code below. It does the "chain chasing" to get
some of the information mentioned in this thread. ​
​Given the responses on another thread, I'm basically abandoning the idea
of "system level C interface" routines, such as for ENQ/DEQ et al. I might
even try to get a decent handle on C++ coding for some of my UNIX stuff.

=== stuff.c ===

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>
int main(int argc, char *argv[])
{
unsigned char *psaaold;
unsigned char *psatold;
unsigned char *ascbjbni;
unsigned char *ascbjbns;
unsigned char *ascbjbn;
unsigned char *ascbcscb;
uint16_t ascbasid;
unsigned char *ascbasxb;
unsigned char *ascbassb;
unsigned char *tcbtio;
unsigned char *a;
static unsigned char jobname[9];
psaaold = *(unsigned char **)0x224; /* address of PSAAOLD */
psatold = *(unsigned char **)0x21c; /* address of PSATOLD */
if (NULL == psaaold) {
printf("PSAAOLD is NULL.\n");
} else {
ascbasid = *(uint16_t *)(psaaold + 36);
printf("ascbasid=%hu %04.4hx\n",ascbasid,ascbasid);
ascbjbni = *(unsigned char **)(psaaold + 0xac);
printf("ascbjbni=%8.8s\n",
(NULL ==
ascbjbni) ? (unsigned char *)"**NULL**" : ascbjbni);
ascbjbns = *(unsigned char **)(psaaold + 0xb0);
printf("ascbjbns=%8.8s\n",
(NULL ==
ascbjbns) ? (unsigned char *)"**NULL**" : ascbjbns);
ascbcscb = *(unsigned char **)(psaaold + 56);
if (NULL == ascbcscb) {
printf("ascbcscb is NULL\n");
} else {
printf("key=%8.8s cls=%8.8s step=%8.8s memnam=%8.8s\n",
ascbcscb + 8, ascbcscb + 16, ascbcscb + 64,
ascbcscb + 64);
}
ascbasxb = *(unsigned char **)(psaaold + 108);
if (NULL == ascbasxb) {
printf("ascbasxb is NULL\n");
} else {
printf("asxbusr8=%8.8s\n", ascbasxb + 192);
}
ascbassb = *(unsigned char **)(psaaold + 336);
if (NULL == ascbassb) {
printf("ascbassb is NULL\n");
} else {
printf
("assbjbni=%8.8s assbjbns=%8.8s assbjobid=%8.8s\n",
ascbassb + 336, ascbassb + 344, ascbassb + 2352);
}
}
if (NULL == psatold) {
printf("PSATOLD is NULL\n");
} else {
tcbtio = *(unsigned char **)(psatold + 12); /* get the address of the TIOT
*/
printf("TIOT info. Jobname=%8.8s Stepname=%8.8s
Procstep=%8.8s\n",tcbtio,(tcbtio+8),(tcbtio+16));
}
}

=== example output ===

ascbasid=60 003c
ascbjbni=BUBBAZ3
ascbjbns=BPXAS
key=BPXAS cls=BPXAS step= memnam=
asxbusr8=BUBBAZ
assbjbni=BUBBAZ3 assbjbns=BPXAS assbjobid=STC02572
TIOT info. Jobname=BUBBAZ3 Stepname=*OMVSEX Procstep=
--
I have a theory that it's impossible to prove anything, but I can't prove
it.

Maranatha! <><
John McKown

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Kirk Wolf
2018-01-14 17:18:26 UTC
Permalink
Uggh.....no wonder people complain about C/C++ :-)

Much better to use the IBM EDCDSECT utility to map the DSECTs that you want
to use into C structs.
We wrote a little REXX wrapper for it that I posted here once so that you
can use edcdsect as a shell command in a Makefile:

ihapsa.h:
echo " IHAPSA" > asm_temp.s
echo " END" >> asm_temp.s
edcdsect.rexx asm_temp.s > ihapsa.h

....


Kirk Wolf
Dovetailed Technologies
http://dovetail.com
Post by John McKown
​Just for fun, I wrote the C code below. It does the "chain chasing" to get
some of the information mentioned in this thread. ​
​Given the responses on another thread, I'm basically abandoning the idea
of "system level C interface" routines, such as for ENQ/DEQ et al. I might
even try to get a decent handle on C++ coding for some of my UNIX stuff.
=== stuff.c ===
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>
int main(int argc, char *argv[])
{
unsigned char *psaaold;
unsigned char *psatold;
unsigned char *ascbjbni;
unsigned char *ascbjbns;
unsigned char *ascbjbn;
unsigned char *ascbcscb;
uint16_t ascbasid;
unsigned char *ascbasxb;
unsigned char *ascbassb;
unsigned char *tcbtio;
unsigned char *a;
static unsigned char jobname[9];
psaaold = *(unsigned char **)0x224; /* address of PSAAOLD */
psatold = *(unsigned char **)0x21c; /* address of PSATOLD */
if (NULL == psaaold) {
printf("PSAAOLD is NULL.\n");
} else {
ascbasid = *(uint16_t *)(psaaold + 36);
printf("ascbasid=%hu %04.4hx\n",ascbasid,ascbasid);
ascbjbni = *(unsigned char **)(psaaold + 0xac);
printf("ascbjbni=%8.8s\n",
(NULL ==
ascbjbni) ? (unsigned char *)"**NULL**" : ascbjbni);
ascbjbns = *(unsigned char **)(psaaold + 0xb0);
printf("ascbjbns=%8.8s\n",
(NULL ==
ascbjbns) ? (unsigned char *)"**NULL**" : ascbjbns);
ascbcscb = *(unsigned char **)(psaaold + 56);
if (NULL == ascbcscb) {
printf("ascbcscb is NULL\n");
} else {
printf("key=%8.8s cls=%8.8s step=%8.8s memnam=%8.8s\n",
ascbcscb + 8, ascbcscb + 16, ascbcscb + 64,
ascbcscb + 64);
}
ascbasxb = *(unsigned char **)(psaaold + 108);
if (NULL == ascbasxb) {
printf("ascbasxb is NULL\n");
} else {
printf("asxbusr8=%8.8s\n", ascbasxb + 192);
}
ascbassb = *(unsigned char **)(psaaold + 336);
if (NULL == ascbassb) {
printf("ascbassb is NULL\n");
} else {
printf
("assbjbni=%8.8s assbjbns=%8.8s assbjobid=%8.8s\n",
ascbassb + 336, ascbassb + 344, ascbassb + 2352);
}
}
if (NULL == psatold) {
printf("PSATOLD is NULL\n");
} else {
tcbtio = *(unsigned char **)(psatold + 12); /* get the address of the TIOT
*/
printf("TIOT info. Jobname=%8.8s Stepname=%8.8s
Procstep=%8.8s\n",tcbtio,(tcbtio+8),(tcbtio+16));
}
}
=== example output ===
ascbasid=60 003c
ascbjbni=BUBBAZ3
ascbjbns=BPXAS
key=BPXAS cls=BPXAS step= memnam=
asxbusr8=BUBBAZ
assbjbni=BUBBAZ3 assbjbns=BPXAS assbjobid=STC02572
TIOT info. Jobname=BUBBAZ3 Stepname=*OMVSEX Procstep=
--
I have a theory that it's impossible to prove anything, but I can't prove
it.
Maranatha! <><
John McKown
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Clark Morris
2018-01-14 20:38:17 UTC
Permalink
[Default] On 14 Jan 2018 09:18:26 -0800, in bit.listserv.ibm-main
Post by Kirk Wolf
Uggh.....no wonder people complain about C/C++ :-)
Much better to use the IBM EDCDSECT utility to map the DSECTs that you want
to use into C structs.
Is there the equivalent utility to map DSECTs to COBOL copy members?

Clark Morris
Post by Kirk Wolf
We wrote a little REXX wrapper for it that I posted here once so that you
echo " IHAPSA" > asm_temp.s
echo " END" >> asm_temp.s
edcdsect.rexx asm_temp.s > ihapsa.h
....
Kirk Wolf
Dovetailed Technologies
http://dovetail.com
?Just for fun, I wrote the C code below. It does the "chain chasing" to get
some of the information mentioned in this thread. ?
?Given the responses on another thread, I'm basically abandoning the idea
of "system level C interface" routines, such as for ENQ/DEQ et al. I might
even try to get a decent handle on C++ coding for some of my UNIX stuff.
=== stuff.c ===
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdint.h>
int main(int argc, char *argv[])
{
unsigned char *psaaold;
unsigned char *psatold;
unsigned char *ascbjbni;
unsigned char *ascbjbns;
unsigned char *ascbjbn;
unsigned char *ascbcscb;
uint16_t ascbasid;
unsigned char *ascbasxb;
unsigned char *ascbassb;
unsigned char *tcbtio;
unsigned char *a;
static unsigned char jobname[9];
psaaold = *(unsigned char **)0x224; /* address of PSAAOLD */
psatold = *(unsigned char **)0x21c; /* address of PSATOLD */
if (NULL == psaaold) {
printf("PSAAOLD is NULL.\n");
} else {
ascbasid = *(uint16_t *)(psaaold + 36);
printf("ascbasid=%hu %04.4hx\n",ascbasid,ascbasid);
ascbjbni = *(unsigned char **)(psaaold + 0xac);
printf("ascbjbni=%8.8s\n",
(NULL ==
ascbjbni) ? (unsigned char *)"**NULL**" : ascbjbni);
ascbjbns = *(unsigned char **)(psaaold + 0xb0);
printf("ascbjbns=%8.8s\n",
(NULL ==
ascbjbns) ? (unsigned char *)"**NULL**" : ascbjbns);
ascbcscb = *(unsigned char **)(psaaold + 56);
if (NULL == ascbcscb) {
printf("ascbcscb is NULL\n");
} else {
printf("key=%8.8s cls=%8.8s step=%8.8s memnam=%8.8s\n",
ascbcscb + 8, ascbcscb + 16, ascbcscb + 64,
ascbcscb + 64);
}
ascbasxb = *(unsigned char **)(psaaold + 108);
if (NULL == ascbasxb) {
printf("ascbasxb is NULL\n");
} else {
printf("asxbusr8=%8.8s\n", ascbasxb + 192);
}
ascbassb = *(unsigned char **)(psaaold + 336);
if (NULL == ascbassb) {
printf("ascbassb is NULL\n");
} else {
printf
("assbjbni=%8.8s assbjbns=%8.8s assbjobid=%8.8s\n",
ascbassb + 336, ascbassb + 344, ascbassb + 2352);
}
}
if (NULL == psatold) {
printf("PSATOLD is NULL\n");
} else {
tcbtio = *(unsigned char **)(psatold + 12); /* get the address of the TIOT
*/
printf("TIOT info. Jobname=%8.8s Stepname=%8.8s
Procstep=%8.8s\n",tcbtio,(tcbtio+8),(tcbtio+16));
}
}
=== example output ===
ascbasid=60 003c
ascbjbni=BUBBAZ3
ascbjbns=BPXAS
key=BPXAS cls=BPXAS step= memnam=
asxbusr8=BUBBAZ
assbjbni=BUBBAZ3 assbjbns=BPXAS assbjobid=STC02572
TIOT info. Jobname=BUBBAZ3 Stepname=*OMVSEX Procstep=
--
I have a theory that it's impossible to prove anything, but I can't prove
it.
Maranatha! <><
John McKown
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Loading...