Help using Base SAS procedures

How to read sdsf jobid into a sas program?

Reply
N/A
Posts: 0

How to read sdsf jobid into a sas program?

Hi,

Can any one suggest how to read sdsf jobid into a sas program?

I am running a SAS Job in z/OS and I want to print the sdsf Jobid in SAS Log then how can this be achieved.
Super Contributor
Super Contributor
Posts: 3,174

Re: How to read sdsf jobid into a sas program?

Posted in reply to deleted_user
SDSF is an output display / management tool accessible through TSO (and batch as well). The JES (Job Entry Subsystem) facility actually assigns the JobID (also called the JES job number to some).

When you refer to "..sdsf Jobid.." - are you actually interested in printing the JES JobID in the SASLOG? And would that be the JOB_NAME or assigned JOB_NUMBER?

If this is the case, I suggest you look at printing the SAS automatic macro variables that are available - issue this command in your job to display them (and choose the appropriate one of interest) - there is a SYSJOBID but that is the JOB_NAME:

%PUT _AUTOMATIC_;

If you are looking to extract the JES-assigned job_number, you will need to investigate using CALL SYSTEM possibly to invoke a REXX EXEC - here is a REXX-related post/article:

http://itknowledgeexchange.techtarget.com/itanswers/can-you-find-out-the-name-of-the-job-calling-a-r...

However, the simplest approach would be to issue a FILENAME statement to allocate an unused and allocate it to SYSOUT=* in your SAS program. Then you can use the PATHNAME CALL function to get back the JES-assigned dataset name, which will include your JOB_NAME and JOB_NUMBER - parse it and display as needed, either with a DATA step or with MACRO language.

Some history: when SAS re-vamped its software with SAS 6.0x in the early '90s, printing of the JOB_NAME and JOB_NUMBER went away and it was up to users to display this information.


Scott Barry
SBBWorks, Inc.
Super Contributor
Posts: 358

Re: How to read sdsf jobid into a sas program?

Posted in reply to deleted_user
I've always used this code (MVS and z/OS) to extract the JES Job Number:

data _null_;

LENGTH JOBNO $8;
ASCBADDR=PEEK(548,4);
ASSBADDR=PEEK(ASCBADDR+336,4);
JSABADDR=PEEK(ASSBADDR+168,4);
JOBNO=PEEKC(JSABADDR+20,8); /* JOB NUMBER */
PUT JOBNO=;

run;
Frequent Contributor
Posts: 106

Re: How to read sdsf jobid into a sas program?

Posted in reply to deleted_user
And here's a bit of the collection that I've been using (based on some REXX code I found in MVS forums):
[pre]
%let tiot_pointer = %sysfunc(peek(%sysfunc(peek(540))+12));
%let job_name = %sysfunc(peekc(&tiot_pointer,8));
%let proc_step = %sysfunc(peekc(&tiot_pointer+8,8));
%let step_name = %sysfunc(peekc(&tiot_pointer+16,8));
%let jscb_pointer = %sysfunc(peek(%sysfunc(peek(540))+180));
%let pgm_name = %sysfunc(peekc(&jscb_pointer+360,8));
%let ssib_pointer = %sysfunc(peek(&jscb_pointer+316));
%let job_id = %sysfunc(peekc(&ssib_pointer+12,8));
%let job_number = %sysfunc(peekc(&ssib_pointer+15,5));
%let jct_pointer = %sysfunc(peek(&jscb_pointer+260));
%let job_class = %sysfunc(peekc(&jct_pointer+47,1));
%let msg_class = %sysfunc(peekc(&jct_pointer+22,1));
%let act_pointer = 00%sysfunc(peekc(&jct_pointer+56,3),hex6.);
%let act_pointer = %sysfunc(inputn(&act_pointer,hex8.));
%let pgmr_field = %sysfunc(peekc(&act_pointer+24,20));
%let system_id = %sysfunc(peek(%sysfunc(peek(16,4))+196,4));
%let system_id = %sysfunc(peekc(&system_id+16,4));
%let user_id = %sysfunc(peek(%sysfunc(peek(548))+108));
%let user_id = %sysfunc(peekc(&user_id+192,8));
[/pre]
Can't tell whether they're still valid with the latest and greatest of z/OS releases (we are at z/OS 1.10 now). Nor can I guarantee for the field names being super-accurate ;-)
Valued Guide
Posts: 2,177

Re: How to read sdsf jobid into a sas program?

Posted in reply to deleted_user
sorry I missed this a couple of weeks ago.
Here is how I get %sysjesID to provide the JES job ID.
%put the sdsf jes job-id is %sysJesID ;
based on my little macro[pre]%macro sysjesid() /des='get jes/sdsf jobID ' ;
%local ascb assb jsab ; %*******mvs jargon ! ;
/* ASCB is at 548 */
/* ASSB is at ASCB+336 */
/* JSAB is at ASSB+168 */
%let ascb = %sysfunc( peek( 548) );
%let assb = %sysfunc( peek( %eval( 336 + &ascb ) ) );
%let jsab = %sysfunc( peek( %eval( 168 + &assb ) ) );
/* now get job ID as in JES/sdsf */
%sysfunc( PEEKc(%eval( 20 + &jsab), 8 ))
%mend sysjesid;
/* demo
%put %sysjesid;
*******************/
Super Contributor
Super Contributor
Posts: 3,174

Re: How to read sdsf jobid into a sas program?

Simplest approach - four lines, no control block references with PEEK:

FILENAME MYDUMMY SYSOUT=*;
%LET MYPATH = %SYSFUNC(PATHNAME(MYDUMMY));
%PUT %SYSFUNC(SCAN(&MYPATH,3,%STR(.)));
FILENAME MYDUMMY CLEAR;

Scott Barry
SBBWorks, Inc.
Valued Guide
Posts: 2,177

Re: How to read sdsf jobid into a sas program?

thanks Scott,
:-( but I like function macros that can be used within statements.
Super Contributor
Super Contributor
Posts: 3,174

Re: How to read sdsf jobid into a sas program?

The process can be done either in a DATA step or with using SAS macro language (invocation) statements.

Scott Barry
SBBWorks, Inc.
Ask a Question
Discussion stats
  • 7 replies
  • 585 views
  • 0 likes
  • 5 in conversation