/* REXX */
/* CLS2REXXed by UMLA01S on 1 Aug 2019 at 18:34:30  */
/*trace ?r*/
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
Address ISREDIT
 
"MACRO"               /* CARM0001 EDIT MACRO TEMP3 */
/*********************************************************************/
/* 05/13/2004 JL.NELSON Created to split out DATA and JCL.           */
/* 06/15/2004 JL.NELSON Added Exit code.                             */
/* 10/26/2004 JL.NELSON Shift ID DSNAME (left blank for expansion).  */
/* 11/18/2004 JL.NELSON Fixed code for group of "GE".                */
/* 02/23/2005 JL.NELSON Changed constants to variables before        */
/*            rename.                                                */
/* 03/15/2005 JL.NELSON Ignore entries not in table cact0001.        */
/* 06/09/2005 JL.NELSON Pass MAXCC in ZISPFRC variable.              */
/* 06/10/2005 JL.NELSON Fixed 912 error on &ML.                      */
/* 04/29/2008 CL.Fenton Changes to determine if discrete profile     */
/*            is available and write command for discrete            */
/*            profile.  Otherwise the generic profile command is     */
/*            used.                                                  */
/* 07/17/2009 CL.Fenton Changes to drop period from end of dsname.   */
/* 08/01/2019 CL.FENTON Converted script from CLIST to REXX.         */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CARM0001 08/01/19"
sysprompt = "OFF"                /* CONTROL NOPROMPT          */
sysflush = "OFF"                /* CONTROL NOFLUSH           */
sysasis = "ON"                 /* CONTROL ASIS - caps off   */
return_code = 0
maxcc = 0
zerrsm = ""
Address ISPEXEC "CONTROL NONDISPL ENTER"
Address ISPEXEC "CONTROL ERRORS RETURN"
/*******************************************/
/* VARIABLES ARE PASSED TO THIS MACRO      */
/*******************************************/
Address ISPEXEC "VGET (CONSLIST COMLIST SYMLIST TERMMSGS TEMP2)",
  "ASIS"
rm01vget = 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 "TEMP2/"temp2
  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                        */
/*******************************************/
syssymlist = symlist          /* CONTROL SYMLIST/NOSYMLIST */
sysconlist = conslist         /* CONTROL CONLIST/NOCONLIST */
syslist    = comlist          /* CONTROL LIST/NOLIST       */
sysmsg     = termmsgs         /* CONTROL MSG/NOMSG         */
/*******************************************/
/* GET DSN                                 */
/*******************************************/
"(MEMBER) = MEMBER"
"(OLDDSN) = DATASET"
/*******************************************/
/* SORT INPUT                              */
/*******************************************/
return_code = 0
"SORT 1 50"
rm01sort = return_code
If return_code > 4 then do
  Say pgmname "SORT RC =" return_code member zerrsm
  SIGNAL  ERR_EXIT
  end
/*******************************************/
/* STARTUP                                 */
/*******************************************/
"(ENDER) = LINENUM .ZLAST"
orptname = ""
members = ""
 
 
/*******************************************/
/* MAIN LOOP                               */
/*******************************************/
LOOP:
do counter = 1 to ender
  return_code = 0
  "(DATA) = LINE" counter
  If left(data,1) = " " |,
     left(data,1) = "*" |,
     left(data,2) = "XX" then iterate
  nrptname = left(data,2)
  parse var data nrptname 4 newac .
  nrptname = left(nrptname,2)
  If orptname <> nrptname then do
    If orptname <> "" then,
      Address ISPEXEC "LMMREP DATAID("temp2") MEMBER("orptname")"
    members = members""orptname
    orptname = nrptname
    end
  ac = " CARC1001 DATASET " newac
  Address ISPEXEC "LMPUT DATAID("temp2") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER("orptname")"
  end
 
 
END_INPUT:
return_code = 0
Address ISPEXEC "LMMREP DATAID("temp2") MEMBER("orptname")"
members = members""orptname
 
/*******************************************/
/* WRITE JCL STATMENTS                     */
/*******************************************/
j1 = "//*"
j2 = "//PSTEP  EXEC RACFSPL"
j3 = "//SYSTSIN  DD DISP=SHR,DSN=&HLQINP..TEMP2"
j4 = "//SYSTSPRT DD DISP=OLD,DSN=&HLQOUT..RACFCMDS.RPT"
j2l = length(j2)
ml = length(members)
Do until members = ""
  mb = left(members,2)
  parse var members mb =3 members
  ac = j1
  Address ISPEXEC "LMPUT DATAID("temp2") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(RACFSPL)"
  ac = "//PSTEP"mb"  EXEC RACFSPL"
  Address ISPEXEC "LMPUT DATAID("temp2") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(RACFSPL)"
  ac = j3"("mb")"
  Address ISPEXEC "LMPUT DATAID("temp2") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(RACFSPL)"
  ac = j4"("mb")"
  Address ISPEXEC "LMPUT DATAID("temp2") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER(RACFSPL)"
  end
ac = j1
Address ISPEXEC "LMPUT DATAID("temp2") MODE(INVAR) DATALOC(AC)",
  "DATALEN("length(ac)") MEMBER(RACFSPL)"
Address ISPEXEC "LMMREP DATAID("temp2") MEMBER(RACFSPL)"
zedsmsg = "FINISHED"
zedlmsg = "Finished processing RACFSPL RC="return_code
Address ISPEXEC "LOG MSG(ISRZ000)"
 
 
/*******************************************/
/* END PROCESSES                           */
/*******************************************/
END_EDIT:
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
rm001rc = return_code
Address ISPEXEC "VPUT (RM01VGET RM01SORT RM001RC) ASIS"
"SAVE"
"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
 
 
