SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
6 REPLIES 6
JackHamilton
Lapis Lazuli | Level 10
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;
=====
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
TSO STATUS and parse the response to get the JES job number.

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
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...
advoss
Quartz | Level 8
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.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
JackHamilton
Lapis Lazuli | Level 10
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.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2262 views
  • 0 likes
  • 4 in conversation