/* REXX */
/* CLS2REXXed by UMLA01S on 4 May 2022 at 15:00:45  */
/*trace ?r*/
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
 
/*********************************************************************/
/* This CLIST (CATC0003) generates reports for selected resources    */
/* through the use of TSS commands, (i.e. TSS WHOHAS and TSS         */
/* WHOOWNS commands).                                                */
/*********************************************************************/
/* 05/04/2022 CL Fenton Converted script from CLIST to REXX.         */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CATC0003 05/04/22"
CONSLIST = "OFF"                  /* DEFAULT IS OFF                  */
COMLIST  = "OFF"                  /* DEFAULT IS OFF                  */
SYMLIST  = "OFF"                  /* DEFAULT IS OFF                  */
TERMMSGS = "OFF"                  /* DEFAULT IS OFF                  */
TRACE    = "OFF"                  /* TRACE ACTIONS AND ERRORS        */
NOUSR    = "OFF"                  /* PRODUCE USER LIST               */
sysflush = "OFF"                  /* CONTROL NOFLUSH                 */
sysprompt = "OFF"                 /* CONTROL NOPROMPT                */
sysasis = "ON"                    /* CONTROL ASIS - caps off         */
Numeric digits 10                 /* default of 9 not enough         */
maxcc = 0
zerrsm           = ""
zerrlm           = ""
zerrmsg          = ""
tc0003_vput_1_error          = 0
tc0003_lminit_catt1001_error = 0
tc0003_lminit_output_error   = 0
tc0003_lminit_temp_error     = 0
tc0003_view_catt1001_error   = 0
tc0003_vget_catt1001_error   = 0
tc0003_edit_output_error     = 0
tc0003_lmcomp_output_error   = 0
return_code = 0
Address ISPEXEC
"CONTROL NONDISPL ENTER"
"CONTROL ERRORS RETURN"
 
Arg OPTION
do until OPTION = ""
  parse var OPTION key"("val")" OPTION
  val = strip(val,"B","'")
  val = strip(val,"B",'"')
  optcmd = key '= "'val'"'
  interpret optcmd
  end
 
return_code = 0
If trace = "ON" then do            /* TURN messages on          */
  termmsgs = "ON"                  /* CONTROL MSG               */
  comlist = "ON"                   /* CONTROL LIST              */
  conslist = "ON"                  /* CONTROL CONLIST           */
  symlist = "ON"                   /* CONTROL SYMLIST           */
  end
 
If CONSLIST = "ON" | COMLIST = "ON" | SYMLIST = "ON" | TRACE = "ON",
  then Trace ?r
 
syssymlist = symlist          /* CONTROL SYMLIST/NOSYMLIST */
sysconlist = conslist         /* CONTROL CONLIST/NOCONLIST */
syslist = comlist             /* CONTROL LIST/NOLIST       */
sysmsg = termmsgs             /* CONTROL MSG/NOMSG         */
zispfrc = 0
"VPUT (ZISPFRC) SHARED"
 
 
MESSAGE_HOUSEKEEPING:
return_code = 0                         /* SET RETURN CODE TO 0 */
"VPUT (CONSLIST COMLIST SYMLIST NOUSR TERMMSGS) ASIS"
If return_code <> 0 then,
  tc0003_vput_1_error = return_code
/********************************************************************/
/* MAIN PROCESS LOOP                                                */
/********************************************************************/
return_code = 0                         /* SET RETURN CODE TO 0 */
"LMINIT DATAID(CATT1001) DDNAME(CNTL)"
If return_code <> 0 then do
  tc0003_lminit_catt1001_error = return_code
  SIGNAL ERR_EXIT
  end
 
"LMINIT DATAID(TEMP) DDNAME(TEMP)"
If return_code <> 0 then do
  tc0003_lminit_temp_error = return_code
  SIGNAL ERR_EXIT    /* EXIT */
  end
 
/*******************************************/
/* Get table values                        */
/*******************************************/
"VIEW DATAID("catt1001") MACRO(CATM1005) MEMBER(CATT1001)"
If return_code > 4 then do
  tc0003_view_catt1001_error = return_code
  SIGNAL ERR_EXIT
  end
 
return_code = 0
"VGET (TABLE TM5VGE) ASIS"
If return_code > 0 then do
  tc0003_vget_catt1001_error = return_code
  SIGNAL ERR_EXIT
  end
 
return_code = 0
"LMINIT DATAID(OUTPUT) DDNAME(OUTPUT) ENQ(EXCLU)"
If return_code > 0 then do
  tc0003_lminit_output_error = return_code
  SIGNAL ERR_EXIT
  end
table = table /* remove after testing */
 
Do INDEX = 1 to length(table) by 15
  tc0003_vput_2_error        = 0
  tc0003_edit_output_error   = 0
  tc0003_lmcomp_output_error = 0
  tc0003_vget_error          = 0
  resource = substr(table,index,15)
  x = outtrap("var.")
  var = left(resource,8)
  var = strip(var,"T")
  auddsns = ""
  varon = ""
  Address TSO "TSS LIST(AUDIT) RESCLASS("var")"
  Do x = 1 to var.0
    data = var.x
    If data = " " then leave
    If substr(data,1,8) <> var then iterate
    auddsn = substr(data,14)
    audx = strip(auddsn,"T")
    laud = length(auddsn)
    audx = strip(audx,"T","*")
    a1 = pos("* ",audx"  ")
    audx = audx
    If audx = "*ALL" then,
      audx = audx"*"
    auddsns = auddsns""left(audx,50)
    end
 
  return_code = 0
  "VPUT (RESOURCE OUTPUT TEMP AUDDSNS) ASIS"
  If return_code > 0 then,
    tc0003_vput_2_error = return_code
 
  return_code = 0
  member = strip("WHOO"substr(resource,9,4),"T")
  "EDIT DATAID("output") MACRO(CATM0005) MEMBER("member")"
  If return_code > 4 then,
    tc0003_edit_output_error = return_code
 
  return_code = 0
  "LMCOMP DATAID("output")"
  If return_code > 0 then,
    tc0003_lmcomp_output_error = return_code
 
  return_code = 0
  "VGET (TM05RC TM05VGE TM06VGE TM07REP TM07VGE) ASIS"
  If return_code > 0 then,
    tc0003_vget_error = return_code
 
  return_code = 0
  If termmsgs = "ON" & tm05rc = 0 then do
    Say "=========================================================="
    Say pgmname "RESOURCE:" var /* substrc(1,8,resource) */
    Say pgmname "VPUT_2_ERROR            "tc0003_vput_2_error
    Say pgmname "EDIT_OUTPUT_ERROR       "tc0003_edit_output_error
    Say pgmname "LMCOMP_OUTPUT_ERROR     "tc0003_lmcomp_output_error
    Say pgmname "VGET_ERROR              "tc0003_vget_error
    Say pgmname "CATM0005 RC             "tm05rc
    Say pgmname "CATM0005 VGET_ERROR     "tm05vge
    Say pgmname "CATM0006 VGET_ERROR     "tm06vge
    If var = "TSOPROC" then do
      Say pgmname "CATM0008 LMMREP_ERROR   "tm07rep
      Say pgmname "CATM0008 VGET_ERROR     "tm07vge
      end
    Else do
      Say pgmname "CATM0007 LMMREP_ERROR   "tm07rep
      Say pgmname "CATM0007 VGET_ERROR     "tm07vge
      end
    end
  end
 
 
ERR_EXIT:
If maxcc >= 16 | return_code > 0 then do
  "VGET (ZISPFRC) SHARED"
  If maxcc > zispfrc then,
    zispfrc = maxcc
  Else,
    zispfrc = return_code
  "VPUT (ZISPFRC) SHARED"
  Say pgmname "ZISPFRC =" zispfrc
  end
  "VGET (ZISPFRC) SHARED"
If termmsgs = "ON" then do
  Say "================================================================"
  Say pgmname "VPUT_1_ERROR            "tc0003_vput_1_error
  Say pgmname "LMINIT_CATT1001_ERROR   "tc0003_lminit_catt1001_error
  Say pgmname "LMINIT_TEMP_ERROR       "tc0003_lminit_temp_error
  Say pgmname "VIEW_CATT1001_ERROR     "tc0003_view_catt1001_error
  Say pgmname "CATM1005 VGET_ERROR     "tm5vge
  Say pgmname "VGET_CATT1001_ERROR     "tc0003_vget_catt1001_error
  Say pgmname "LMINIT_OUTPUT_ERROR     "tc0003_lminit_output_error
  Say pgmname "ZISPFRC =" zispfrc
  Say "================================================================"
  end
Exit 0
 
 
/*******************************************/
/*  SYSCALL SUBROUTINES                    */
/*******************************************/
 
 
NoValue:
Failure:
Syntax:
say pgmname 'REXX error' rc 'in line' sigl':' strip(ERRORTEXT(rc))
say SOURCELINE(sigl)
SIGNAL ERR_EXIT
 
 
Error:
return_code = RC
if RC > 4 & RC <> 8 then do
  say pgmname "LASTCC =" RC strip(zerrlm)
  say pgmname 'REXX error' rc 'in line' sigl':' strip(ERRORTEXT(rc))
  say SOURCELINE(sigl)
  if return_code > maxcc then
    maxcc = return_code
  end
return
 
 
