IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Using REXX to access SDSF; What am I doing wrong?


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tom.glaser

New User


Joined: 08 Dec 2020
Posts: 15
Location: US

PostPosted: Wed Dec 16, 2020 12:21 am
Reply with quote

I'm now pulling my hair out....just about bald. Here's more testing:

This produces a good successful token if I go against a non db2 job.

Code:

/* rexx */
 RC=ISFCALLS("ON")
 isfprefix=mvsvar('symdef','jobname')
 isffilter = 'QUEUE EQ EXECUTION'
 isffiltermode='AND'
 ADDRESS SDSF 'ISFEXEC ST'
 say 'this is JNAME1= 'JNAME.1
 say 'this is queue1= 'queue.1
 say 'this is jobid1= 'jobid.1
 say 'this is token.1 = 'token.1
 say 'isfdisplay: ' isfdisplay
.
.
.
ACF0C038 ACF2 LOGONID ATTRIBUTES HAVE REPLACED DEFAULT USER ATTRIBUTES
this is JNAME1= D2ADME1A
this is queue1= EXECUTION
this is jobid1= JOB28057
this is token.1 = zDsjAhAcEpKEccHBUMXwQPx1wdXsxdxAze3PbAoBA4EAJgQ1lFXxTg0QBwANJiOExNLB3NTEZEDF+0LE1bVyQMXmTcTAFCeCNgoxMSMBA4EAJgQ1F
R0IFfE=
isfdisplay:  PREFIX=D2ADME1A DEST=(ALL) OWNER=D2ADME1 SYSNAME= FILTERS=1
tom, this is at 2nd token = zDsjAhAcEpKEccHBUMXwQPx1wdXsxdxAze3PbAoBA4EAJgQ1lFXxTg0QBwANJiOExNLB3NTEZEDF+0LE1bVyQMXmTcTAFCeCNgoxMSM
BA4EAJgQ1FR0IFfE=
12:36:49 41 lines read from list


but...I'm able to get a token if I remove this:

isfprefix=mvsvar('symdef','jobname')

It has something to do with that line. If I remove it, then I'm not able to find the executing job.

Code:

END
ACF0C038 ACF2 LOGONID ATTRIBUTES HAVE REPLACED DEFAULT USER ATTRIBUTES
this is JNAME1= D2ADME1
this is queue1= EXECUTION
this is jobid1= TSU25903
this is token.1 = zDsjAhAcEpKEccHBUMXwQPx1wdXsxdxAzdziQVwBA4EAJgQ1lFXxTg0QBwANJiOExNLB3NTEZEDF+0LE1bVyQMXmTcTAJhOkNgc4NCcBA4EAJgQ1l
B0IVaA=
this is token.2 = TOKEN.2
this is token.3 = TOKEN.3
this is token.4 = TOKEN.4
this is token.5 = TOKEN.5
isfdisplay:  PREFIX=D2ADME1* DEST=(ALL) OWNER=D2ADME1 SYSNAME= FILTERS=1
tom, this is at 2nd token = zDsjAhAcEpKEccHBUMXwQPx1wdXsxdxAzdziQVwBA4EAJgQ1lFXxTg0QBwANJiOExNLB3NTEZEDF+0LE1bVyQMXmTcTAJhOkNgc4NCc
BA4EAJgQ1lB0IVaA=


Is there a way to find what I need without using:

isfprefix=mvsvar('symdef','jobname')

CPUF STATUS DISPLAY ALL CLASSES LINE 1-8 (8)
COMMAND INPUT ===> SCROLL ===> PAGE
PREFIX=D2ADME1A DEST=(ALL) OWNER=* SORT=Rd-Date//D Rd-Time//D SYSNAME=*
NP JOBNAME JobID Max-RC Owner Prty Queue C Pos SAff ASys Status
D2ADME1A JOB28108 D2ADME1 4 EXECUTION E CPUF CPUF
D2ADME1A JOB28107 CC 0000 D2ADME1 1 PRINT E 8851
D2ADME1A JOB28093 CC 3657 D2ADME1 1 PRINT E 8846
D2ADME1A JOB28092 CC 0000 D2ADME1 1 PRINT E 8844
D2ADME1A JOB28090 CC 3657 D2ADME1 1 PRINT E 8842
D2ADME1A JOB28086 CC 3657 D2ADME1 1 PRINT E 8841
D2ADME1A JOB28065 CC 3657 D2ADME1 1 PRINT E 8835
D2ADME1A JOB28061 CC 3657 D2ADME1 1 PRINT E 8834

Thanks, Tom
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Wed Dec 16, 2020 4:08 am
Reply with quote

I am a bit confused here.
You last display indicates that you are looking for D2ADME1A JOB28108, but you REXX displays says

this is JNAME1= D2ADME1
this is queue1= EXECUTION
this is jobid1= TSU25903

Jobid indicates a TSO user, not a batch job.

Anyway, this kinda crude pgm might show a bit of light...
Code:
 n=isfcalls('ON')                                         
                                                           
 say 'I am:' mvsvar('symdef','jobname')                   
 isfprefix=mvsvar('symdef','jobname')                     
 isfowner ='*'                                             
 Address SDSF "ISFEXEC ST"                                 
 say 'ST rc:' rc                                           
 say 'display opts:' isfdisplay                           
 say 'Jobname  Queue      Jobid    DDnamen'               
 do n=1 to jname.0                                         
   Address SDSF "ISFACT ST TOKEN('"token.n"') PARM(NP SA)"
   say left(jname.n,8) left(queue.n,10) jobid.n           
   do o=1 to isfddname.0                                   
     say left(' ',30) right(o,4) isfddname.o isfdsname.o   
   end                                                     
 end                                                       
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Wed Dec 16, 2020 9:48 am
Reply with quote

The "Cancel a job" example from SDSF User's Guide, SC27-9028-30 uses this:
Code:
isfprefix="**"
isfowner="*"

However, the manual does not explain them well; instead they refer you to read the online ISPF help.

Depending on your system settings, there are some obscure rules about the job name being your userid followed by a single letter suffix. In your examples, sometimes you had a W or Q as the suffix. I think using the entire job name as the prefix causes a different result than what you expect.

Perhaps use:
Code:
isfprefix="D2ADME1*"

But to be more robust, get the jobname using the MVSVAR('symdef','jobname') function and then replace the last character with an asterisk.
Back to top
View user's profile Send private message
tom.glaser

New User


Joined: 08 Dec 2020
Posts: 15
Location: US

PostPosted: Wed Dec 16, 2020 8:14 pm
Reply with quote

Thanks Willy, Pedro.

I took Willy's code and ran it as is....results don't make sense. Our jobs must be userid + 1 char, as Pedro points out. Here's the first run:

Code:

I AM: D2ADME1A
ST RC: 0
DISPLAY OPTS: PREFIX=D2ADME1A DEST=(ALL) OWNER=* SYSNAME=
JOBNAME  QUEUE      JOBID    DDNAMEN
D2ADME1A EXECUTION  JOB39182
                                  1 SYS00001 D2ADME1.D2ADME
                                  2 SYS00002 D2ADME1.D2ADME
                                  3 SYS00003 D2ADME1.D2ADME
                                  4 SYS00004 D2ADME1.D2ADME
                                  5 SYS00005 D2ADME1.D2ADME
D2ADME1A PRINT      JOB39049
                                  1 SYS00006 D2ADME1.D2ADME
                                  2 SYS00007 D2ADME1.D2ADME
                                  3 SYS00008 D2ADME1.D2ADME
                                  4 SYS00009 D2ADME1.D2ADME
                                  5 SYS00010 D2ADME1.D2ADME
D2ADME1A PRINT      JOB39058
                                  1 SYS00011 D2ADME1.D2ADME
                                  2 SYS00012 D2ADME1.D2ADME
                                  3 SYS00013 D2ADME1.D2ADME
                                  4 SYS00014 D2ADME1.D2ADME
.
.
.


Here's the second run:

Code:

I AM: D2ADME1A
ST RC: 0
DISPLAY OPTS: PREFIX=D2ADME1A DEST=(ALL) OWNER=* SYSNAME=
JOBNAME  QUEUE      JOBID    DDNAMEN
D2ADME1A PRINT      JOB39049
                                  1 SYS00001 D2ADME1.D2ADME1A.
                                  2 SYS00002 D2ADME1.D2ADME1A.
                                  3 SYS00003 D2ADME1.D2ADME1A.
                                  4 SYS00004 D2ADME1.D2ADME1A.
                                  5 SYS00005 D2ADME1.D2ADME1A.
D2ADME1A PRINT      JOB39058
                                  1 SYS00006 D2ADME1.D2ADME1A.
                                  2 SYS00007 D2ADME1
                                  3 SYS00008 D2ADME1
                                  4 SYS00009 D2ADME1
                                  5 SYS00010 D2ADME1
D2ADME1A PRINT      JOB39067
                                  1 SYS00011 D2ADME1
                                  2 SYS00012 D2ADME1
                                  3 SYS00013 D2ADME1
                                  4 SYS00014 D2ADME1
                                  5 SYS00015 D2ADME1
D2ADME1A PRINT      JOB39081
                                  1 SYS00016 D2ADME1
                                  2 SYS00017 D2ADME1
                                  3 SYS00018 D2ADME1
                                  4 SYS00019 D2ADME1
                                  5 SYS00020 D2ADME1
D2ADME1A PRINT      JOB39106


What I noticed is that the first job worked....it found the job executing. Job JOB39182. Since then, every job I submit, it does not show the executing job. Here's the 5th run of this job:

Code:

I AM: D2ADME1A
ST RC: 0
DISPLAY OPTS: PREFIX=D2ADME1A DEST=(ALL) OWNER=* SYSNAME=
JOBNAME  QUEUE      JOBID    DDNAMEN
D2ADME1A PRINT      JOB39049
                                  1 SYS00001 D2ADME1.D2ADME1A
                                  2 SYS00002 D2ADME1.D2ADME1A
                                  3 SYS00003 D2ADME1.D2ADME1A
                                  4 SYS00004 D2ADME1.D2ADME1A
                                  5 SYS00005 D2ADME1.D2ADME1A
D2ADME1A PRINT      JOB39058
                                  1 SYS00006 D2ADME1.D2ADME1A
                                  2 SYS00007 D2ADME1.D2ADME1A
                                  3 SYS00008 D2ADME1.D2ADME1A
                                  4 SYS00009 D2ADME1.D2ADME1A
                                  5 SYS00010 D2ADME1.D2ADME1A
D2ADME1A PRINT      JOB39067
                                  1 SYS00011 D2ADME1.D2ADME1A


As you can see, the new code I ran from Willy is showing that sometimes it works, and most of the time is does not. Which is what I'm seeing in all my tests. The key question, why isn't the new code picking up the executing job? I'm going to run a few more tests. Thanks again, Tom
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Wed Dec 16, 2020 10:12 pm
Reply with quote

Quote from Pedro:
Quote:
Depending on your system settings, there are some obscure rules about the job name being your userid followed by a single letter suffix

I have never come across that myself, but it is worth a try.
Try again, but change the isfprefix=mvsvar('symdef','jobname')
to
isfprefix=strip(left(mvsvar('symdef','jobname'),7))'*'
say 'prefix:' isfprefix
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Thu Dec 17, 2020 4:47 am
Reply with quote

It might be useful to also get the job number of your currently executing job:

Code:
/* REXX */
PSATOLD = C2X(STORAGE(21C,4))                   /* GET OLD TCB ADDR  */
TCBA = PSATOLD
JSCBA = C2X(STORAGE(D2X(X2D(TCBA) + 180),4))    /* GET JSCB ADDR     */
JSCBACT = C2X(STORAGE(D2X(X2D(JSCBA) + 348),4)) /* ACTIVE JSCB ADDR  */
SSIBA = C2X(STORAGE(D2X(X2D(JSCBACT) + 316),4)) /* GET SSIB ADDR     */

JOBNO = STORAGE(D2X(X2D(SSIBA) + 12),8)         /* GET JOB NUMBER    */
SAY 'JOB NUMBER='JOBNO
EXIT
Back to top
View user's profile Send private message
tom.glaser

New User


Joined: 08 Dec 2020
Posts: 15
Location: US

PostPosted: Thu Dec 17, 2020 7:23 pm
Reply with quote

I got it to work.....I talked to someone at IBM. Here's what I learned:

The problem is timing. The job is trying to look at "itself" on the ST display. When SDSF requests data from JES for that display we use the extended statsus SSI. That interface returns all the jobs known to JES at the time the data was checkpointed by JES2. That data may or may not contain the executing job, depending on when the job entered the system and then tried to "find" itself. If a checkpoint was not taken in between those times, the job may not show up at all (or I suppose could show up on the input queue). The way I could consistently have my test job work and "see" itself was to add a "wait" of 10 seconds before the ST call is made (10 seconds is likely more than enough of a delay but it depends on the checkpoint interval and when the job entered the JES queue.

You have helped me so much. I have one follow-up question and then I think I'm good to start writing my code. I'd like to look at the whole sysout. Today, I see what's in SYSTSPRT. I did read more in the redbook about using JDS and DDNAMES.

In the sample, it showed:

Address SDSF "ISFACT ST TOKEN('"TOKEN.1"') PARM(NP ?)" ,
"( prefix jds_"

Is this where I specify the DDNAME like JESYSMSG?

Tom
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Thu Dec 17, 2020 9:41 pm
Reply with quote

Wow. I had a similar timing issue a few weeks ago. I didn’t chime in earlier because I didn’t make the connection to your situation. In my case I put in a 2 second wait.

Thanks for providing that explanation from IBM. I wasn’t sure why my solution worked.

In my case I was using a Rexx SDSF step at the start of my job that scans the JCL from the running job and deletes data sets that will be cataloged by subsequent steps in the job. Normally I would use a CA11RMS step for this purpose, but I was running on a zDT instance where that program is not available.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Dec 17, 2020 10:08 pm
Reply with quote

don.leahy wrote:
In my case I was using a Rexx SDSF step at the start of my job that scans the JCL from the running job and deletes data sets that will be cataloged by subsequent steps in the job. Normally I would use a CA11RMS step for this purpose, but I was running on a zDT instance where that program is not available.

Care to share that code, I think it would be useful for more of us!
Back to top
View user's profile Send private message
Willy Jensen

Active Member


Joined: 01 Sep 2015
Posts: 712
Location: Denmark

PostPosted: Thu Dec 17, 2020 10:23 pm
Reply with quote

I love forums like this, even (very) old dogs can learn new tricks.
Re 'Is this where I specify the DDNAME like JESYSMSG' - I would say no. You either know the number associated with JESYSMSG (my latest sample pgm could help you there), or you do something like this:
Code:
Address SDSF "ISFACT ST TOKEN('"token.n"') PARM(NP SA)" 
 do o=1 to isfdsname.0                                   
   if right(isfdsname.o,8)='JESMSGLG' then ...           
 end   

And perhaps there is a case for a new topic: how to wait in REXX. Or this has most probably already been covered.
Depending on the case I use either
Code:
 call syscalls 'ON'               
 Address syscall 'sleep' secs     
 call syscalls 'OFF'               

or the RXWAIT pgm from www.cbttape.org file 669.
Any takers?
Back to top
View user's profile Send private message
tom.glaser

New User


Joined: 08 Dec 2020
Posts: 15
Location: US

PostPosted: Thu Dec 17, 2020 11:16 pm
Reply with quote

Here's what I used:

Code:

SECONDS=10
say ' '
say "Entering wait mode for" SECONDS "SECONDS..."
ADDRESS SYSCALL "SLEEP (SECONDS)"


Thanks everyone for your help. I learned a lot!

Tom
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Thu Dec 17, 2020 11:26 pm
Reply with quote

prino wrote:
don.leahy wrote:
In my case I was using a Rexx SDSF step at the start of my job that scans the JCL from the running job and deletes data sets that will be cataloged by subsequent steps in the job. Normally I would use a CA11RMS step for this purpose, but I was running on a zDT instance where that program is not available.

Care to share that code, I think it would be useful for more of us!
If it was just up to me, certainly. But, my employer has very strict intellectual property rules. I could ask, but it would probably take months to run it up the chain of command before it reached a point where someone could make a decision. At the moment only two other people in the company even know that the thing exists. It was one of those “spare time” projects that started when my zDT sysprog declined to install CA11RMS in that environment.

I didn’t want to go back to manually coding an IEFBR14 step to do the cleanup, so I went with the Rexx SDSF approach. One of the big advantages is that you can look at the JESJCL which has all of the symbols resolved.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Dec 18, 2020 12:25 am
Reply with quote

don.leahy wrote:
prino wrote:
don.leahy wrote:
In my case I was using a Rexx SDSF step at the start of my job that scans the JCL from the running job and deletes data sets that will be cataloged by subsequent steps in the job. Normally I would use a CA11RMS step for this purpose, but I was running on a zDT instance where that program is not available.

Care to share that code, I think it would be useful for more of us!
If it was just up to me, certainly. But, my employer has very strict intellectual property rules. I could ask, but it would probably take months to run it up the chain of command before it reached a point where someone could make a decision. At the moment only two other people in the company even know that the thing exists. It was one of those “spare time” projects that started when my zDT sysprog declined to install CA11RMS in that environment.

When I left my employer in the mid-nineties, I asked if I could take all of the REXX execs I had written in the three or four years I used REXX, the rather surprising reply was "We wouldn't be surprised if you had already made copies!"

My employer was an insurance broker, their business wasn't writing software, which might explain the reply. And I also promised that they could also contact me is they ever needed help with any of the code. I don't remember if they ever did, I do know that when I returned to them later (as a contractor for Y2K and euro work) I updated quite a few of the execs and obviously made copies of them. ;)

If I were ever offered another job, sadly pretty unlikely as the market for PL/I is tiny, and more so for someone over 60, I would make it a condition of my employment contract that everything not company-specific I write would be covered by an open source license! As is now the case with everything you can find on my Prino's z/OS Tools and utilities page, where I chose, love it or loathe it, the GPL.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Dec 18, 2020 12:32 am
Reply with quote

gsf-soft.com/Freeware/FILE183-index.html

CLEANUP does just that
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Sat Nov 13, 2021 10:17 pm
Reply with quote

Gilbert Saint-Flour was a brilliant guy. I have been a fan for many years. He was taken from us much too soon.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX Goto page Previous  1, 2

 


Similar Topics
Topic Forum Replies
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
Search our Forums:

Back to Top