/* REXX */
/* CLS2REXXed by FSOX001 on 7 Jun 2017 at 14:31:09  */
/*trace ?r*/
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
Address ISREDIT
 
"MACRO"               /* CARM0041 EDIT TEMP4(*) */
/*********************************************************************/
/* Script written to provide a report on specific resource classes.  */
/* 06/09/2017 CL.FENTON Converted script from CLIST to REXX.         */
/*            Also added GROUPID user list processing (CARM0005),    */
/*            STS-017060.                                            */
/* 08/28/2019 CL.FENTON Changes include a limit of 1000 userids      */
/*            being extracted until all userids are collected for    */
/*            groups with excessive number of userids to avoid an    */
/*            error on variable LIDLIST, STS-022967.                 */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CARM0041 08/18/19"
sysprompt = "OFF"                /* CONTROL NOPROMPT          */
sysflush = "OFF"                /* CONTROL NOFLUSH           */
sysasis = "ON"                 /* CONTROL ASIS - caps off   */
Address ISPEXEC "CONTROL NONDISPL ENTER"
Address ISPEXEC "CONTROL ERRORS RETURN"
 
/*******************************************/
/* VARIABLES ARE PASSED TO THIS MACRO      */
/*******************************************/
maxcc = 0
return_code = 0
Address ISPEXEC "VGET (TEMP5 RACFRPT CONSLIST COMLIST SYMLIST",
  "BETA TERMMSGS NOULST CARM0005 LISTGRP) ASIS"
 
rm4vge = 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
  Say pgmname "TEMP5/"temp5 "RACFRPT/"racfrpt "NOULST/"noulst,
    "BETA/"beta "CARM0005/"carm0005 "LISTGRP/"listgrp
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
If CONSLIST = "ON" | COMLIST = "ON" | SYMLIST = "ON" ,
  then Trace ?r
 
return_code = 0
/*******************************************/
/* SET MESSAGES                            */
/*******************************************/
syssymlist = symlist          /* CONTROL SYMLIST/NOSYMLIST */
sysconlist = conslist         /* CONTROL CONLIST/NOCONLIST */
syslist = comlist          /* CONTROL LIST/NOLIST       */
sysmsg = termmsgs         /* CONTROL MSG/NOMSG         */
 
outline = left("L",133,"-")
dsname1 = ""
dsname2 = ""
dsname3 = ""
dsname4 = ""
grplist = ""
curline = 1
sortsw = "A"
 
"(MEMBER) = MEMBER"
omember = member
blank = " "
racfpro = " "
"(ENDER) = LINENUM .ZLAST"
sortstr = "10 60 133 133 62 69"
If beta = 1 then,
  sortstr = "10 36 133 133 62 69"
If beta = 2 then,
  sortstr = "10 15 133 133 62 69 21 33"
"SORT" sortstr
"CHANGE ALL ' ' 'N' 81"
x = outtrap("line.",3)
 
 
/*******************************************/
/* MAIN LOOP                               */
/*******************************************/
LOOP:
do curline = 1 to ender
  "(DATA) = LINE" curline
 
  data = data
  parse var data racfres 10 dsname2 62 uzid 71 acc1 81 group 83 warn1,
    86 uacc1 95 audit1 133 .
  uzid = left(uzid,8)
  if group = "N" & uzid <> " " then do
    cmd = "LISTUSER" uzid
    return_code = 0
    Address TSO cmd
    If return_code = 0 then do
      "X ALL '"uzid"' 62 69"
      "CHANGE ALL 'N' 'U' 81 EX"
      "RESET"
      group = "U"
      end
    Else do
      cmd = "LISTGRP" uzid
      return_code = 0
      Address TSO cmd
      If return_code = 0 then do
        "X ALL '"uzid"' 62 69"
        "CHANGE ALL 'N' 'G' 81 EX"
        "RESET"
        group = "G"
        end
      end
    end
  grpacc = "ACCESS("left(acc1,8)")"
  If omember = "GDASDVOL" |,
     omember = "GCICSTRN" |,
     omember = "TCICSTRN" then,
    dsname4 = left(dsname2,11)
 
  acc1 = strip(acc1,"T")
 
/*******************************************/
/* FIND OUT IF NEW DSNAME                  */
/*******************************************/
  acc2 = acc1
  If omember = "GDASDVOL" |,
     omember = "GCICSTRN" |,
     omember = "TCICSTRN" then do
    If dsname3 <> dsname4 then do
      if dsname3 <> "" then do
        ac = outline
        Address ISPEXEC "LMPUT DATAID("temp5") MODE(INVAR)",
          "DATALOC(AC) DATALEN("length(ac)") MEMBER("omember")"
        end
      dsname3 = dsname4
      end
    end
  Else,
    If dsname1 <> dsname2 then do
      if dsname1 <> "" then do
        ac = outline
        Address ISPEXEC "LMPUT DATAID("temp5") MODE(INVAR) DATALOC(AC)",
          "DATALEN("length(ac)") MEMBER("omember")"
        end
      dsname1 = dsname2
      end
 
/*******************************************/
/* IF NOT READ ACCESS - PROCESS            */
/*******************************************/
  If group = " " |,
     group = "N" |,
     group = "U" then do
    ac = "D"racfres""dsname2
    ac = left(ac,60)" "uzid
    ac = left(ac,69)" "acc2
    ac = left(ac,78)"  "group
    ac = left(ac,81)"  "warn1
    ac = left(ac,85)" "uacc1
    ac = left(ac,94)" "audit1
    Address ISPEXEC "LMPUT DATAID("temp5") MODE(INVAR) DATALOC(AC)
      DATALEN("length(ac)") MEMBER("omember")"
    end
  If group = "G" then do
    grpusr = "GROUPID("uzid")"
    If acc1 = "NONE" |,
       acc1 = "EXECUTE" then,
      nop
    Else do
      ac = "D"racfres""dsname2
      ac = left(ac,60)" "uzid
      ac = left(ac,69)" "acc2
      ac = left(ac,78)"  "group
      ac = left(ac,81)"  "warn1
      ac = left(ac,85)" "uacc1
      ac = left(ac,94)" "audit1
      Address ISPEXEC "LMPUT DATAID("temp5") MODE(INVAR)",
        "DATALOC(AC) DATALEN("length(ac)") MEMBER("omember")"
 
      If pos(uzid,grplist) = 0 then do
        lidrc = 0
        lidline = 1
        grplist = grplist uzid
/*      Address ISPEXEC "VPUT (UZID SORTSW) ASIS"
        Address ISPEXEC "EDIT DATAID("racfrpt") MACRO("carm0005")",
          "MEMBER("listgrp")"
        grplist = grplist uzid
        Address ISPEXEC "VGET (LIDLIST) ASIS"
        call Process_groupid*/
        do until lidrc > 0
          Address ISPEXEC "VPUT (UZID SORTSW LIDRC LIDLINE) ASIS"
          Address ISPEXEC "EDIT DATAID("racfrpt") MACRO("carm0005")",
            "MEMBER("listgrp")"
          Address ISPEXEC "VGET (LIDLIST LIDRC LIDLINE) ASIS"
          Call Process_groupid
          lidline = lidline + 1
          end
        end
      end
    end
 
 
BYPASS_NEXT_PROCESS:
  end
 
 
/*******************************************/
/* SAVE OUTPUT                             */
/*******************************************/
END_EDIT:
return_code = 0
Address ISPEXEC "LMMADD DATAID("temp5") MEMBER("omember")"
If return_code = 4 then do
  return_code = 0
  Address ISPEXEC "LMMREP DATAID("temp5") MEMBER("omember")"
  If return_code <> 0 then do
    Say pgmname "LMMREP_TEMP5_RC =" return_code omember zerrsm
    end
  end
Else do
  If return_code <> 0 then,
    Say pgmname "LMMADD_TEMP5_RC =" return_code omember zerrsm
  end
return_code = 0
 
 
ERR_EXIT:
If maxcc >= 16 | return_code > 4 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
 
Address ISPEXEC "VPUT (RM4VGE) ASIS"
"END"
Exit 0
 
 
Process_groupid:
data = "    "grpusr grpacc
 
do xx = 1 to length(lidlist) by 28
  parse var lidlist . =(xx) user +8 name +20 .
  ac = strip(data,"T") "USER="user "NAME="name
  Address ISPEXEC "LMPUT DATAID("temp5") MODE(INVAR)",
    "DATALOC(AC) DATALEN("length(ac)") MEMBER("omember")"
  end
return_code = 0
return
 
 
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':' strip(ERRORTEXT(rc))
  say SOURCELINE(sigl)
  end
if return_code > maxcc then
  maxcc = return_code
return
 
 
