/* REXX */
/* CLS2REXXed by UMLA01S on 13 Jan 2020 at 15:05:51  */
/*trace ?r*/
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
Address ISREDIT
 
"MACRO"               /* CARM0403 EDIT RACFCMDS.RPT(*)  */
/*********************************************************************/
/* 05/13/2004 JL Nelson Created to display new findings.             */
/* 06/15/2004 JL Nelson Added exit code.                             */
/* 06/29/2004 JL Nelson changed data set check to SYSDSN BIF.        */
/* 11/05/2004 JL Nelson Changed for dataset alias's LISTDSI BIF.     */
/* 01/28/2005 JL Nelson Changed Generic sort order.                  */
/* 02/23/2005 JL Nelson Changed constants to variables before        */
/*            rename.                                                */
/* 03/09/2005 JL Nelson Changed LMMADD/LMMREP error messages.        */
/* 06/09/2005 JL Nelson Pass MAXCC in ZISPFRC variable.              */
/* 03/07/2006 JL Nelson Made changes to avoid abend 920/932.         */
/* 09/10/2007 CL.Fenton Merger AUDIT with UACC and WARN entry.       */
/* 04/13/2017 CL.Fenton Corrected issue with FIRSTPO and LASTPO      */
/*            being equal.                                           */
/* 01/13/2020 CL Fenton Converted script from CLIST to REXX.         */
/* 09/08/2020 CL Fenton Added IF statement for TRACE.                */
/* 01/11/2021 CL.Fenton Correction made to not display messages      */
/*            being displayed from listdsi.                          */
/* 01/26/2023 CL.Fenton Added Address ISPEXEC "CONTROL ...           */
/*            statements.                                            */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CARM0003 01/26/23"
sysprompt = "OFF"                /* CONTROL NOPROMPT          */
sysflush = "OFF"                /* CONTROL NOFLUSH           */
sysasis = "ON"                 /* CONTROL ASIS - caps off   */
/*******************************************/
/* VARIABLES ARE PASSED TO THIS MACRO      */
/* CONSLIST                                */
/* COMLIST                                 */
/* TERMMSGS                                */
/*******************************************/
return_code = 0
zerrsm = ""
Address ISPEXEC "VGET (CONSLIST COMLIST SYMLIST TERMMSGS TEMP4)",
  "ASIS"
rm03vget = return_code
If return_code <> 0 then do
  Say pgmname "VGET RC =" return_code zerrsm
  Say pgmname "CONSLIST/"conslist "COMLIST/"comlist,
    "SYMLIST/"symlist "TERMMSGS/"termmsgs "TEMP4/"temp4
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
If CONSLIST = "ON" | COMLIST = "ON" | SYMLIST = "ON" ,
  then Trace r
return_code = 0
/*******************************************/
/* TURN ON MESSAGES                        */
/*******************************************/
Address ISPEXEC "CONTROL NONDISPL ENTER"
Address ISPEXEC "CONTROL ERRORS RETURN"
syssymlist = symlist          /* CONTROL SYMLIST/NOSYMLIST */
sysconlist = conslist         /* CONTROL CONLIST/NOCONLIST */
syslist = comlist             /* CONTROL LIST/NOLIST       */
sysmsg = termmsgs             /* CONTROL MSG/NOMSG         */
"(MEMBER) = MEMBER"
omember = member
maxcc = 0
lp = "("
rp = ")"
blk44 = "                                            "
sysouttrap = 99999
 
/*******************************************/
/* MAIN LOOP                               */
/*******************************************/
"(ENDER) = LINENUM .ZLAST"
"CURSOR = 1 0"
curline = 0
 
 
LOOP_DA:
txt = outtrap('txt.')
do forever
  return_code = 0
  curline = curline + 1
  If curline > ender then leave
 
/*******************************************/
/* LOOK FOR DATASET                        */
/*******************************************/
  return_code = 0
  "(DATA) = LINE" curline
  data = strip(data,"T")
  If pos("CARC1001",data) > 0 then do
    parse var data . 20 dsname .
    iterate
/*  firstpo = 20
    lastpo = pos(" ",data,21) - 1
    If firstpo <= lastpo then,
      dsname = substrc(firstpo,lastpo,data)*/
    end
 
  If pos("INFORMATION FOR",data) > 0 then do
    /*******************************************/
    /* STRIP PROFILE                           */
    /*******************************************/
    lastpo = length(data)
    racfpro = substr(data,25)
    ac = left(racfpro,44)
    ac = ac"4DSNAME   "dsname
    Address ISPEXEC "LMPUT DATAID("temp4") MODE(INVAR) DATALOC(AC)",
      "DATALEN("length(ac)") MEMBER("omember")"
    iterate
    end
 
  If pos("RESOURCE NOT FO",data) > 0 then do
    return_code = 0
    if right(dsname,1) = "." then dsn = strip(dsname,"T",".")
    else dsn = dsname
    rc = listdsi("'"dsn"'")
    listdsi_dsn_rcode = return_code + rc
    listdsi_dsn_reason = sysreason
    say pgmname dsname dsn sysdsname rc sysreason
    If sysreason = 0 then do
      If dsname = sysdsname then,
        racfpro = "SRR YES0 No rule exists for this data set"
      Else,
        racfpro = "SRR N/A  This is a data set ALIAS"
      end
    Else,
      racfpro = "SRR N/A  The data set does not exist"
    ac = left(racfpro,44)
    ac = ac"4DSNAME   "dsname
    Address ISPEXEC "LMPUT DATAID("temp4") MODE(INVAR) DATALOC(AC)",
      "DATALEN("length(ac)") MEMBER("omember")"
    iterate
    end
  /*******************************************/
  /* STRIP UACC                              */
  /*******************************************/
  If pos("UNIVERSAL ACCESS",data) > 0 then do
    warn1 = ""
    curline = curline + 2
    "(DATA) = LINE" curline
    uacc1 = word(data,3)
    warn1 = word(data,4)
    If warn1 = "YES" then,
      warn1 = "WARN(Y)"
    Else,
      warn1 = "WARN(N)"
    uacc = strip(uacc1,"B")
    uacc = "UACC("uacc")"
    ac = left(racfpro,44)
    ac = left(ac"1"uacc,59)warn1
    iterate
    end
/*******************************************/
/* LOOK FOR AUDIT PARMS                    */
/*******************************************/
  If pos("AUDITING",data) = 1 then do
    audit1 = ""
    curline = curline + 2
    "(DATA) = LINE" curline
    /*******************************************/
    /* SET AUDIT 1 = AUDIT PARMS               */
    /*******************************************/
    audit1 = strip(data,"T")
    ac = left(racfpro,44)
    ac = ac"1"uacc
    ac = left(ac,59)warn1
    ac = left(ac,67)"AUDIT("audit1")"
    Address ISPEXEC "LMPUT DATAID("temp4") MODE(INVAR)",
      "DATALOC(AC) DATALEN("length(ac)") MEMBER("omember")"
    iterate
    end
/*******************************************/
/* LOOK FOR WHO IS USING DATASET           */
/*******************************************/
  If "   ID     ACCESS" = data then do
    curline = curline + 2
    do until data = " "
      "(DATA) = LINE" curline
      if data = " " | words(data) > 2 then leave
      word8 = left(word(data,1),8)
      If word8 = "*" then
        groupid = "6GENERIC("word8")"
      Else,
        groupid = "8GROUPID("word8")"
      word8 = left(word(data,2),8)
      grpacc = "ACCESS("word8")"
      outline = left(groupid,19) left(grpacc,18)
      ac = left(racfpro,44)
      ac = ac""outline
      Address ISPEXEC "LMPUT DATAID("temp4") MODE(INVAR) DATALOC(AC)",
        "DATALEN("length(ac)") MEMBER("omember")"
      curline = curline + 1
      end
    end
  end
 
 
END_EDIT:
return_code = 0
Address ISPEXEC "LMMADD DATAID("temp4") MEMBER("omember")"
If return_code = 4 then do
  return_code = 0
  Address ISPEXEC "LMMREP DATAID("temp4") MEMBER("omember")"
  If return_code <> 0 then do
    Say pgmname "LMMREP_TEMP4_RCODE =" return_code omember zerrsm
    end
  end
Else do
  If return_code <> 0 then,
    Say pgmname "LMMADD_TEMP4_RCODE =" return_code omember zerrsm
  end
return_code = 0
 
 
ERR_EXIT:
If maxcc > 16 | return_code > 0 then do
  Address ISPEXEC "VGET (ZISPFRC) SHARED"
  If maxcc > zispfrc then,
    zispfrc = maxcc
  Else,
    zispfrc = return_code
  Address ISPEXEC "VPUT (ZISPFRC) SHARED"
  Say pgmname "ZISPFRC =" zispfrc
  end
rm003rc = return_code
Address ISPEXEC "VPUT (RM03VGET RM03FER RM003RC) ASIS"
"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 >= 16 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
 
 
