/* REXX */
/* CLS2REXXed by UMLA01S on 8 Dec 2023 at 09:08:22  */
/*Trace ?r*/
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
 
/*********************************************************************/
/* 06/01/2004 JL.NELSON CREATE to check data set FINDINGS.           */
/* 06/18/2004 JL.NELSON ADDED EXIT CODE.                             */
/* 06/23/2004 JL.NELSON ADDED code to check security system.         */
/* 01/20/2005 JL.NELSON Changed to add dslist to PDIs.               */
/* 02/28/2005 JL.NELSON Changed constants to variables.              */
/* 03/22/2005 JL.NELSON PDI member maybe blank, old CACT0000.        */
/* 03/23/2005 JL.NELSON Added TYPERUN for Reports without PDIs.      */
/* 06/09/2005 JL.NELSON Pass MAXCC in ZISPFRC variable.              */
/* 06/15/2005 JL.NELSON Reset return code to end job step.           */
/* 09/10/2007 CL.Fenton Added resource collection.  Chgd several     */
/*            variables and routines being executed by process.      */
/* 07/16/2009 CL.FENTON Changes CACT0001 to CACT0000, CACM042V to    */
/*            CACM000T.  Changes for reflect new table information.  */
/* 08/29/2016 CL.FENTON Correct issue with TBLMBR.                   */
/* 12/08/2023 CL Fenton Converted script from CLIST to REXX.         */
/* 03/14/2025 CL Fenton Changed all entries for rptname to pdimbr,   */
/*            SCTASKU0323303.                                        */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CARC0421 03/14/25"
CONSLIST = "OFF"                  /* DEFAULT IS OFF                  */
COMLIST  = "OFF"                  /* DEFAULT IS OFF                  */
SYMLIST  = "OFF"                  /* DEFAULT IS OFF                  */
TERMMSGS = "OFF"                  /* DEFAULT IS OFF                  */
TYPERUN = "FSO"                   /* Run for SRRAUDIT | FSO          */
CACC1000 = "CACC1000"             /* SELECT SECURITY CHECK PGM       */
CACT0000 = "CACT0000"             /* SELECT MVS REPORT TABLE         */
CACT0008 = "CACT0008"             /* SELECT RESOURCE TABLE           */
CACM000T = "CACM000T"             /* SELECT edit macro/CACT0000      */
CACM042R = "CACM042R"             /* SELECT edit macro/CACT0008      */
CARM0421 = "CARM0421"             /* SELECT EDIT MACRO/SENSITVE      */
CARM0422 = "CARM0422"             /* SELECT EDIT MACRO/SENSITVE      */
CARM0423 = "CARM0423"             /* AAMV0420                        */
PDILIMIT = "999999"               /* Limit output PDIs               */
PDIDDN = "PDIDD"                  /* PDI DDNAME IN JCL               */
SENSDDN = "SENSITVE"              /* SENSITVE DDNAME IN JCL          */
TEMP6DDN = "TEMP6"                /* TEMP6 DDNAME IN JCL             */
CNTLDDN = "CNTL"                  /* CNTL DDNAME IN JCL              */
TRACE = "OFF"                     /* TRACE ACTIONS AND ERRORS        */
sysprompt = "OFF"                 /* CONTROL NOPROMPT                */
sysflush = "OFF"                  /* CONTROL NOFLUSH                 */
sysasis = "ON"                    /* CONTROL ASIS - caps off         */
lminit_pdidd_rc     = "N/A"
lminit_sensitve_rc  = "N/A"
lminit_cntl_rc      = "N/A"
lmopen_pdidd_rc     = "N/A"
lmopen_sensitve_rc  = "N/A"
view_cact0000_rc    = "N/A"
cm00trc             = "N/A"
cm0tvget            = "N/A"
cm0tvput            = "N/A"
rm21vget            = "N/A"
rm421rc             = "N/A"
rm22vget            = "N/A"
rm422rc             = "N/A"
lmcomp_pdidd_rc     = "N/A"
lmclose_pdidd_rc    = "N/A"
lmclose_sensitve_rc = "N/A"
lmfree_pdidd_rc     = "N/A"
lmfree_sensitve_rc  = "N/A"
lmfree_cntl_rc      = "N/A"
Numeric digits 10                 /* default of 9 not enough         */
maxcc = 0
 
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
 
If trace = "ON" then do
  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
Address ISPEXEC
"CONTROL NONDISPL ENTER"
"CONTROL ERRORS RETURN"
"VPUT (ZISPFRC) SHARED"
return_code = 0
"VPUT (CONSLIST COMLIST SYMLIST TERMMSGS CARM0422 PDILIMIT",
   "TYPERUN) ASIS"
rc21vput = return_code
If return_code <> 0 then do
  Say pgmname "VPUT RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
/* Determine which security system is running */
 
return_code = 0
"SELECT CMD("cacc1000 "ACP)"
"VGET (ACPNAME ACPVERS) ASIS"
If acpname <> "RACF" then do
  Say pgmname "RACF Job running on the wrong system"
  Say pgmname acpname acpvers
  Say pgmname "CCACPRC =" ccacprc
  return_code = 20
  SIGNAL ERR_EXIT
  end
 
/*******************************************/
/* INITIALIZE LIBRARY MANAGEMENT           */
/*******************************************/
 
return_code = 0
"LMINIT DATAID(PDIDD) DDNAME("pdiddn")"
lminit_pdidd_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT PDIDD RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
"LMINIT DATAID(SENSITVE) DDNAME("sensddn")"
lminit_sensitve_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT SENSITVE RC =" return_code  zerrsm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
"LMINIT DATAID(TEMP6) DDNAME("temp6ddn")"
lminit_temp6_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT TEMP6 RC =" return_code  zerrsm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
"LMINIT DATAID(CNTL) DDNAME("cntlddn")"
lminit_cntl_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT CNTL RC =" return_code  zerrsm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
x = listdsi(pdiddn "FILE")
listdsi_file_rcode = return_code
listdsi_file_reason = sysreason
If sysreason = 0 then do
  odsname = sysdsname
  listdsi_file_msglvl2 = sysmsglvl2
  end
Else do
  Say pgmname "Unable to determine PDI DSNAME SYSREASON" sysreason
  Say pgmname sysmsglvl1
  Say pgmname sysmsglvl2
  end
 
/*******************************************/
/* OPEN DATASETS                           */
/*******************************************/
return_code = 0
"LMOPEN DATAID("pdidd") OPTION(OUTPUT)"
lmopen_pdidd_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN PDIDD RC =" return_code  zerrsm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
"LMOPEN DATAID("sensitve") OPTION(INPUT)"
lmopen_sensitve_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN SENSITVE RC =" return_code  zerrsm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
"LMOPEN DATAID("temp6") OPTION(INPUT)"
lmopen_temp6_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN TEMP6 RC =" return_code  zerrsm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
/*******************************************/
/* PUT VARS IN POOL                        */
/*******************************************/
"VPUT (PDIDD SENSITVE TEMP6 CNTL CACT0000) ASIS"
 
/*******************************************/
/* GET TABLE VALUES                        */
/*******************************************/
return_code = 0
"VIEW DATAID("cntl") MACRO("cacm000t") MEMBER("cact0000")"
view_cact0000_rc = return_code
 
return_code = 0
"VGET (CM0TVGET CM0TVPUT CM00TRC TBLMBR) ASIS"
If view_cact0000_rc > 4 then do
  Say pgmname "VIEW CNTL" cact0000  "RC =" cm00trc  zerrsm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
resource = "DSNAME"
"VPUT (RESOURCE) ASIS"
 
/*******************************************/
/* EDIT RACF REPORTS                       */
/*******************************************/
/*SET TBLMBR = &NRSTR(&TBLMBR.#)*/
 
tblmbr = strip(tblmbr,"L","#")
do until tblmbr = ""
  parse var tblmbr tabledata "#" tblmbr
  parse var tabledata 1 iter 3 . 4 rptmbr 12 pdimbr 22 title "@" .
  rptmbr = strip(rptmbr,"B")
  pdimbr = strip(pdimbr,"B")
  return_code = 0
  If pdimbr = " " then iterate
/*  SIGNAL DO_END     No entry in CACT0000*/
  "LMMFIND DATAID("temp6") MEMBER("pdimbr")"
  If return_code = 0 then do
    /*******************************************/
    /* PUT VARS IN POOL                        */
    /*******************************************/
    return_code = 0
    "VPUT (PDIMBR RPTMBR ODSNAME) ASIS"
    return_code = 0
    "VIEW DATAID("temp6") MACRO("carm0421") MEMBER("pdimbr")"
    If return_code > 4 then,
        Say pgmname "VIEW_TEMP6_RC =" return_code "MEMBER" pdimbr,
          "for" rptmbr zerrsm
    end
 
 
DO_END:
  end
 
pdimbr = "AAMV0420"
"SELECT CMD("carm0423")"
If return_code > 4 then,
  Say pgmname "AAMV0420_RC =" return_code "MEMBER" pdimbr zerrsm
 
rectype = 1
pdiname = ""
resname = ""
"VPUT (RECTYPE PDINAME RESNAME) ASIS"
 
return_code = 0
"VIEW DATAID("cntl") MEMBER("cact0008") MACRO("cacm042r")"
view_cact0008_rc = return_code
If view_cact0008_rc > 4 then do
  Say pgmname "VIEW CNTL" cact0008  "RC =" view_cact0008_rc
  return_code = return_code + 16
  SIGNAL END_EXIT
  end
 
"VGET (REC1TBL) ASIS"
return_code = 0
Do X = 1 to length(rec1tbl) by 18
  parse var rec1tbl . =(x) pdimbr resource .
  pdimbr = strip(pdimbr,"T")
  rptmbr = pdimbr
  return_code = 0
  "LMMFIND DATAID("temp6") MEMBER("pdimbr")"
  If return_code <> 0 then do
    Say pgmname "LMMFIND_RACFRPT_RC =" return_code "MEMBER =",
      pdimbr zerrsm
    end
  Else do
    /*******************************************/
    /* PUT VARS IN POOL                        */
    /*******************************************/
    "VPUT (PDIMBR RPTMBR RESOURCE) ASIS"
    return_code = 0
    "VIEW DATAID("temp6") MACRO("carm0421") MEMBER("pdimbr")"
    If return_code > 4 then,
      Say pgmname "VIEW_RACFRPT_RC =" return_code "MEMBER =",
        pdimbr zerrsm
    end
  end
 
 
END_EXIT:
/*******************************************/
/* CLOSE OUTPUT                            */
/*******************************************/
return_code = 0
"LMCLOSE DATAID("pdidd")"
lmclose_pdidd_rc = return_code
return_code = 0
"LMCLOSE DATAID("sensitve")"
lmclose_sensitve_rc = return_code
return_code = 0
"LMCLOSE DATAID("temp6")"
lmclose_temp6_rc = return_code
return_code = 0
"LMCOMP DATAID("pdidd")"
lmcomp_pdidd_rc = return_code
 
/*******************************************/
/* FREE FILES                              */
/*******************************************/
return_code = 0
"LMFREE DATAID("sensitve")"
lmfree_sensitve_rc = return_code
return_code = 0
"LMFREE DATAID("temp6")"
lmfree_temp6_rc = return_code
return_code = 0
"LMFREE DATAID("pdidd")"
lmfree_pdidd_rc = return_code
return_code = 0
"LMFREE DATAID("cntl")"
lmfree_cntl_rc = return_code
return_code = 0
 
 
/*******************************************/
/* ERROR EXIT                              */
/*******************************************/
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 (RM21VGET RM421RC RM22VGET RM422RC CM42VRC) ASIS"
If termmsgs = "ON" then do
  Say "==============================================================="
  Say pgmname "LMINIT_PDIDD_RC         " lminit_pdidd_rc
  Say pgmname "LMINIT_SENSITVE_RC      " lminit_sensitve_rc
  Say pgmname "LMINIT_CNTL_RC          " lminit_cntl_rc
  Say "==============================================================="
  Say pgmname "LMOPEN_PDIDD_RC         " lmopen_pdidd_rc
  Say pgmname "LMOPEN_SENSITVE_RC      " lmopen_sensitve_rc
  Say "==============================================================="
  Say pgmname "VIEW_CACT0000_RC        " view_cact0000_rc
  Say pgmname cacm000t "CM00TRC        " cm00trc
  If cm00trc <> 0 then do
    Say pgmname cacm000t "VGET           " cm0tvget
    Say pgmname cacm000t "VPUT           " cm0tvput
    end
  Say pgmname carm0421 "VGET           " rm21vget
  Say pgmname carm0421 "RM421RC        " rm421rc
  Say pgmname carm0422 "VGET           " rm22vget
  Say pgmname carm0422 "RM422RC        " rm422rc
  Say "==============================================================="
  Say pgmname "LMCOMP_PDIDD_RC         " lmcomp_pdidd_rc
  Say pgmname "LMCLOSE_PDIDD_RC        " lmclose_pdidd_rc
  Say pgmname "LMCLOSE_SENSITVE_RC     " lmclose_sensitve_rc
  Say pgmname "LMFREE_PDIDD_RC         " lmfree_pdidd_rc
  Say pgmname "LMFREE_SENSITVE_RC      " lmfree_sensitve_rc
  Say pgmname "LMFREE_CNTL_RC          " lmfree_cntl_rc
  Say "==============================================================="
  end
Exit 0
 
 
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":" ERRORTEXT(rc)
  say SOURCELINE(sigl)
  end
if return_code > maxcc then,
  maxcc = return_code
return
 
 
