Home > Tools > Customizing SYSPROC at TSO Logon time

Customizing SYSPROC at TSO Logon time

One of the things I like to do is to allocate my own REXX library to SYSPROC at TSO logon time so that I can execute REXX commands simply by typing in “TSO command_name”  on the ISPF command line.

On the TSO logon screen I have a command setup to invoke a REXX exec that will do that for me:

TSO_Logon_Screen

BEFORE just says to allocate my REXX library before the existing allocations so that anything in my library overrides anything in the existing allocation with the same name (useful for testing changes to existing EXECs). Specify ‘AFTER’ or let it default to allocate your library AFTER the existing allocations.

This is the exec (called ALLOCREX in the above screen shot):

/* rexx                                                    */
/* logon exec to concat my rexx library to SYSPROC so that */
/* I can run my own rexx commands easily without having    */
/* to specify the dataset name. EG TSO MYEXEC              */
/*                                                         */

parse arg opt                 /* BEFORE or AFTER (default) */

lib=userid()||".REXX"         /* dsn of rexx lib to alloc  */
if x> 4 then do
   say "Unable to locate '"lib"'."
   say 'SYSPROC alloc not changed.'
   signal exit
   end

rc=ddns('SYSPROC')    /* get current SYSPROC allocation */

/* extract dsns and check for my rexx lib already alloc */
list=''
comma=''
do while queued() > 0
   parse pull dsn
   if dsn=lib then do
      say lib 'already concat to SYSPROC.'
      say 'SYSPROC alloc not changed.'
      signal exit
   end
   list=list||comma||"'"||strip(dsn)||"'"
   comma=','
end
oldlist=list

/* add my rex lib to the list and realloc the DD */
if opt = 'BEFORE' then do
   list="'"lib"',"||list
end
else do
   list=list||",'"lib"'"
end
"ALLOC F(SYSPROC) DATASET("list") SHR REUSE"
allocrc=rc
if allocrc <> 0 then do
   say 'Alloc of SYSPROC faiuled with rc='allocrc
   say 'Restoring original allocation'
   "ALLOC F(SYSPROC) DATASET("oldlist") SHR REUSE"
   end

/* queue an ISPF command so this exec can end */
exit:
queue 'ISPF'
return 0
/*---------------------------------------------------------*/
ddns: procedure
/*---------------------------------------------------------*/
/*  Find dsns allocated to a specified ddname              */
/*  Output returned on the stack                           */
/*---------------------------------------------------------*/
/*                                                         */
parse arg ddname
upper ddname
x=outtrap("out.","*","noconcat",1)
address TSO 'listalc status'
if out.0 = 0  then do
  return 0    /* Nothing found */
  end

foundDD="N"
do i=1 to out.0 by 2
   parse var out.i dsn .
   j=i+1
   ddn=strip(substr(out.j,3,8))
   if ddn <> "" & ddn = ddname then foundDD="Y"
   if ddn <> "" & ddn <> ddname then foundDD="N"
   if foundDD = "Y" then do
      push dsn
   end
end
return 0
Advertisements
Categories: Tools Tags:
  1. Jeffrey
    July 17, 2015 at 8:26 pm

    Why are you not allocating REXX programs the the REXX DD SYSEXEC? In theory, the rexx programs should be in their own library and SYSEXEC should be pointing to REXX programs.

  2. July 17, 2015 at 9:22 pm

    In theory, yes, you are correct but in practical terms you can use either. I’ve just always used SYSPROC. I guess that comes from it being the command list library since before REXX was supported and there were only CLISTs.

  3. Jeffrey
    July 17, 2015 at 10:28 pm

    Very good then…thanks for sharing your code with us. It will come in very handy for those who don’t have a method to do this.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: