DATA Step, Macro, Functions and more

Looking for the Job Number

Reply
N/A
Posts: 0

Looking for the Job Number

I can get &sysjobid to give me the job name but I can not find any command to get the TSO job number.

Is there one or does any one have a method to do so?
Frequent Contributor
Posts: 102

Re: Looking for the Job Number

Posted in reply to deleted_user
Found this somewhere on the intertubes:

=====
DATA ZZGETUSR
(Drop=TIOTPTR JSCBPTR SSIBPTR JCTPTR ACTPTR
Label='User information on MVS job');

LENGTH PROGRAMR $20 JOBNAME $8 PROCSTEP $8
STEPNAME $8 PROGNAME $8 JOBNUMBR $8
USERID $8
;

TIOTPTR = peek(peek(540) + 12);

JOBNAME = peekc(TIOTPTR, 8);

PROCSTEP = peekc(TIOTPTR+8, 8);

STEPNAME = peekc(TIOTPTR+16, 8);

JSCBPTR = peek(peek(540) + 180);

PROGNAME = peekc(JSCBPTR + 360, 8);

SSIBPTR = peek(JSCBPTR + 316);

JOBNUMBR = peekc(SSIBPTR + 12, 8);

JCTPTR = peek(JSCBPTR + 260);

JOBCLASS = peekc(JCTPTR + 47, 1);

MSGCLASS = peekc(JCTPTR + 22, 1);

ACTPTR = INPUT('00'X || peekc(JCTPTR + 56, 3), PIB4.);

PROGRAMR = peekc(ACTPTR + 24, 20);
SYSTEMID = PEEKC(PEEK(peek(16, 4) + 196, 4) + 16, 4);
USERID = peekc(peek(peek(548) + 108) + 192, 8);

put (_character_) (=/);

run;
=====
Super Contributor
Super Contributor
Posts: 3,174

Re: Looking for the Job Number

Posted in reply to deleted_user
TSO STATUS and parse the response to get the JES job number.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Looking for the Job Number

Posted in reply to deleted_user
Just so you all know... I could not get the first routine to work and I already had the TSO STATUS command but our system people would not let us use it.

However, I did get this to work and it is great.... all the information I need,,

DATA _NULL_;
FILE RPTOUT;
%SYSEXEC STATUS "&SYSJOBID";
LENGTH JOBNO $8;
ASCBADDR=PEEK(548,4);
ASSBADDR=PEEK(ASCBADDR+336,4);
JSABADDR=PEEK(ASSBADDR+168,4);
/* JOB NUMBER */
JOBNO=PEEKC(JSABADDR+20,8);
PUT JOBNO=;
RUN;

Thanks to both of you for responding so quickly...
Frequent Contributor
Posts: 91

Re: Looking for the Job Number

Posted in reply to deleted_user
Batch job?
At our site, the JOBNAME and JOBID are used to name temporary SYSOUT datasets, so the following code works nicely without all of the peeking around.

//JOBNAME JOB (ACCTINFO),'DUMMYJOB '
//STEP1OF1 EXEC SASMVS,SASLOG='*',SASLIST='*'
//JOBINFO DD SYSOUT=* /* DO NOT CHANGE...USED TO GET JOBID */
//SYSIN DD *
PROC SQL NOPRINT;
SELECT SCAN(XPATH,2,'.'),SCAN(XPATH,3,'.') INTO
:JOBNAME SEPARATED BY ' ',
:JOBID SEPARATED BY ' '
FROM DICTIONARY.EXTFILES
WHERE FILEREF = 'JOBINFO';
QUIT;
%PUT !&JOBNAME!&JOBID!;

Just checked...works for interactive SAS on TSO, too.
Super Contributor
Super Contributor
Posts: 3,174

Re: Looking for the Job Number

Posted in reply to deleted_user
Honestly, it's ridiculous that your SYSPROGs do not permit you to use the TSO STATUS command...for any reason at all. Slick circumvention with the temp DSN allocation / inquiry though.

Scott Barry
SBBWorks, Inc.
Frequent Contributor
Posts: 102

Re: Looking for the Job Number

I agree about the silliness of not allowing the STATUS command - but lots of places practice security theatre - just for show, no real value - so I'm not surprised it happens.
Ask a Question
Discussion stats
  • 6 replies
  • 188 views
  • 0 likes
  • 4 in conversation