/* REXX */
/* CLS2REXXed by FSOX001 on 5 Jul 2016 at 10:41:04  */
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
 
/*********************************************************************/
/* 05/04/2004 JL.NELSON CHANGED TO COLLECT NEW RACF FINDINGS         */
/* 06/15/2004 JL.NELSON CHANGED TO fix Top Secret checks             */
/* 06/18/2004 JL.NELSON ADDED EXIT CODE                              */
/* 06/23/2004 JL.NELSON ADDED code to check security system          */
/* 08/10/2004 JL.NELSON Made parmlib a variable that can be passed   */
/* 10/25/2004 JL.NELSON Use table CACT0401 for group identifiers     */
/* 10/26/2004 JL.NELSON Use STCLIST to identify STC group ids        */
/* 10/28/2004 JL.NELSON Use MSTJCL to find PROC libraries            */
/* 10/28/2004 JL.NELSON Added code for GRS dataset list              */
/* 11/01/2004 JL.NELSON Added code to check members before EDIT      */
/* 12/02/2004 JL.NELSON Changed for all fields in TBLMBR             */
/* 02/11/2005 JL.NELSON Changed constants to variables before rename */
/* 02/28/2005 JL.NELSON Added CMD(CACC1000 PARM)                     */
/* 03/14/2005 JL.NELSON Changed to use old table                     */
/* 03/16/2005 JL.NELSON Correct length error code 864                */
/* 03/22/2005 JL.NELSON Added TYPERUN for Reports without PDIs       */
/* 04/06/2005 JL.NELSON Added code for master catalog ACP00130       */
/* 04/06/2005 JL.NELSON Combined JES2 reports ACP00150/ACP00160      */
/* 04/21/2005 JL.NELSON Changed to use default PARMLIB               */
/* 04/21/2005 JL.NELSON Changed JES2PARM datasets to goto JES2RPT    */
/* 06/09/2005 JL.NELSON Pass MAXCC in ZISPFRC variable               */
/* 06/15/2005 JL.NELSON Reset return code to end job step            */
/* 07/18/2005 JL.NELSON View CACT0001 from CNTL for FSO TSS mod.     */
/* 03/03/2006 JL.NELSON Made changes to avoid SUBSTR abend 920/932.  */
/* 03/09/2006 JL.NELSON Set/test RCode for every ISPEXEC command.    */
/* 03/20/2006 JL.NELSON Use NRSTR avoid abend 900 if ampersand in    */
/*            data.                                                  */
/* 03/20/2007 CL.FENTON Removed PARM, PROCLIBS, & PROCRPT process    */
/* 03/20/2007 CL.FENTON Removed checks on IEASYS, MSTJCL, & JES2     */
/*            mbrs.                                                  */
/* 03/20/2007 CL.FENTON Chgd DSNLIST to specify DSNLIST mbr.         */
/* 03/20/2007 CL.FENTON Removed PAGE dsns process.                   */
/* 06/02/2009 CL.FENTON Changes CACT0001 to CACT0000, CACM042T to    */
/*            CACM000T.  Changes for reflect new table information.  */
/* 07/11/2016 CL.FENTON Converted script from CLIST to REXX.         */
/* 06/14/2018 CL.FENTON Deleted CACM0420 varible.                    */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
CONSLIST = "OFF"                  /* DEFAULT IS OFF                  */
COMLIST  = "OFF"                  /* DEFAULT IS OFF                  */
SYMLIST  = "OFF"                  /* DEFAULT IS OFF                  */
TERMMSGS = "OFF"                  /* DEFAULT IS OFF                  */
DSNLIST  = "DSNLIST"              /* DEFAULT DSNLIST                 */
STCLIST  = "STCILIST"             /* DEFAULT STC LIST                */
GRSLIST  = "GRSILIST"             /* DEFAULT GRS LIST                */
TYPERUN  = "FSO"                  /* Run for SRRAUDIT | FSO          */
CACT0000 = "CACT0000"             /* DEFAULT ID TABLE                */
CACC1000 = "CACC1000"             /* Security check program          */
CACM000T = "CACM000T"             /* Edit macro for CT0401/stc*      */
CACM0401 = "CACM0001"             /* Edit macro for APF/LINK/LPA     */
CACM0403 = "CACM0003"             /* Edit macro for JES2 parms       */
CACM0404 = "CACM0004"             /* Edit macro for JES2 procs       */
CACM0405 = "CACM0005"             /* Edit macro for DSNLIST          */
CACM0406 = "CACM0006"             /* Edit macro for temp3            */
CACM0421 = "CACM0421"             /* Edit macro for GRSLIST          */
CACM1001 = "CACC1001"             /* Edit macro for DSNLIST          */
DUPSBY   = "DSN"                  /* DELETE DUPS BY DSN | GROUP      */
NUCLDSN  = "SYS1.NUCLEUS"         /* Default NUCLEUS library         */
TRACE    = "OFF"                  /* TRACE ACTIONS AND ERRORS        */
pgmname = "CACC0001 06/14/18"
 
sysprompt = "OFF"                 /* CONTROL NOPROMPT                */
sysflush = "OFF"                  /* CONTROL NOFLUSH                 */
sysasis = "ON"                    /* CONTROL ASIS - caps off         */
Numeric digits 10                 /* default of 9 not enough         */
maxcc = 0
lmcopy_dsnlist_rc  = 0
lmcopy_stclist_rc  = 0
lmcopy_apfxrpt_rc  = 0
lmcopy_lnkxrpt_rc  = 0
lmcopy_lpaxrpt_rc  = 0
lmcopy_pptxrpt_rc  = 0
lmcopy_mvsxrpt_rc  = 0
lmcopy_smfxrpt_rc  = 0
lmcopy_catxrpt_rc  = 0
lmcopy_smperpt_rc  = 0
lmcopy_jes2exam_rc = 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
 
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         */
Address ISPEXEC
"CONTROL NONDISPL ENTER"
"CONTROL ERRORS RETURN"
zispfrc = 0
"VPUT (ZISPFRC) SHARED"
return_code = 0
"VPUT (CONSLIST COMLIST SYMLIST TERMMSGS STCLIST CACT0000",
  "TYPERUN NUCLDSN ) ASIS"
cc01vput = return_code
If return_code <> 0 then do
  Say pgmname "VPUT RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
exit_cc = 0
blk44 = "                                            "
/* Determine which security system is running */
return_code = 0
"SELECT CMD("cacc1000 "ACP)"
"VGET (ACPNAME ACPVERS) ASIS"
If acpname = " " then do
  Say pgmname "Unable to determine security system."
  end
/*******************************************/
/* INITIALIZE LIBRARY MANAGEMENT           */
/*******************************************/
"LMINIT DATAID(EXAMRPT) DDNAME(EXAMRPT)"
lminit_examrpt_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT EXAMRPT  RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = listdsi("EXAMRPT" "FILE")
listdsi_exam_rcode = return_code
listdsi_exam_reason = sysreason
If sysreason = 0 then do
  examdsn = sysdsname
  listdsi_exam_msglvl2 = sysmsglvl2
  end
Else do
  listdsi_exam_msglvl1 = sysmsglvl1
  listdsi_exam_msglvl2 = sysmsglvl2
  end
return_code = 0
"LMINIT DATAID(CNTLID) DDNAME(CNTL)"                  /* INSTALL/USER */
lminit_cntl_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT CNTL     RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = listdsi("CNTL" "FILE")
listdsi_cntl_rcode = return_code
listdsi_cntl_reason = sysreason
If sysreason = 0 then do
  cntldsn = sysdsname
  listdsi_cntl_msglvl2 = sysmsglvl2
  end
Else do
  listdsi_cntl_msglvl1 = sysmsglvl1
  listdsi_cntl_msglvl2 = sysmsglvl2
  end
return_code = 0
"LMINIT DATAID(TEMP1) DDNAME(TEMP1)"                  /* INIT TEMP1 */
lminit_temp1_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT TEMP1    RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = listdsi("TEMP1" "FILE")
listdsi_temp1_rcode = return_code
listdsi_temp1_reason = sysreason
If sysreason = 0 then do
  temp1dsn = sysdsname
  listdsi_temp1_msglvl2 = sysmsglvl2
  end
Else do
  listdsi_temp1_msglvl1 = sysmsglvl1
  listdsi_temp1_msglvl2 = sysmsglvl2
  end
return_code = 0
"LMINIT DATAID(TEMP2) DDNAME(TEMP2)"                  /* INIT TEMP2 */
lminit_temp2_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT TEMP2    RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = listdsi("TEMP2" "FILE")
listdsi_temp2_rcode = return_code
listdsi_temp2_reason = sysreason
If sysreason = 0 then do
  temp2dsn = sysdsname
  listdsi_temp2_msglvl2 = sysmsglvl2
  end
Else do
  listdsi_temp2_msglvl1 = sysmsglvl1
  listdsi_temp2_msglvl2 = sysmsglvl2
  end
return_code = 0
"LMINIT DATAID(TEMP3) DDNAME(TEMP3)"                  /* INIT TEMP3 */
lminit_temp3_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT TEMP3    RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
/*******************************************/
/* COPY DSNLST FROM CNTL PDS               */
/*******************************************/
return_code = 0
lmcopy_dsnlist_rc = copymbr(cntlid,dsnlist,temp2,"DSNLIST","c")
 
return_code = 0
lmcopy_stclist_rc = copymbr(cntlid,stclist,temp2,,"c")
If lmcopy_stclist_rc <> 0 then do
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
/*******************************************/
/* COPY EXAMINE MEMBERS                    */
/*******************************************/
EXAMINE_COPY:
return_code = 0
mbrrpt = "APFXRPT"
lmcopy_apfxrpt_rc = copymbr(examrpt,mbrrpt,temp1,,"e")
If lmcopy_apfxrpt_rc <> 0 then
  exit_cc = 4
 
return_code = 0
mbrrpt = "LNKXRPT"
lmcopy_lnkxrpt_rc = copymbr(examrpt,mbrrpt,temp1,,"e")
If lmcopy_lnkxrpt_rc <> 0 then
  exit_cc = 4
 
return_code = 0
mbrrpt = "LPAXRPT"
lmcopy_lpaxrpt_rc = copymbr(examrpt,mbrrpt,temp1,,"e")
If lmcopy_lpaxrpt_rc <> 0 then
  exit_cc = 4
 
return_code = 0
mbrrpt = "PPTXRPT"
lmcopy_pptxrpt_rc = copymbr(examrpt,mbrrpt,temp1,,"e")
If lmcopy_pptxrpt_rc <> 0 then
  exit_cc = 4
 
return_code = 0
mbrrpt = "MVSXRPT"
lmcopy_mvsxrpt_rc = copymbr(examrpt,mbrrpt,temp1,,"e")
If lmcopy_mvsxrpt_rc <> 0 then
  exit_cc = 4
 
return_code = 0
mbrrpt = "SMFXRPT"
lmcopy_smfxrpt_rc = copymbr(examrpt,mbrrpt,temp1,,"e")
If lmcopy_smfxrpt_rc <> 0 then
  exit_cc = 4
 
return_code = 0
mbrrpt = "CATURPT"
lmcopy_catxrpt_rc = copymbr(examrpt,mbrrpt,temp1,,"e")
If lmcopy_catxrpt_rc <> 0 then
  exit_cc = 4
 
return_code = 0
mbrrpt = "SMPERPT"
lmcopy_smperpt_rc = copymbr(examrpt,mbrrpt,temp1,,"e")
If lmcopy_smperpt_rc <> 0 then
  exit_cc = 4
 
return_code = 0
mbrrpt = "JES2PARM"
lmcopy_jes2exam_rc = copymbr(examrpt,mbrrpt,temp1,,"e")
If lmcopy_jes2exam_rc <> 0 then
  exit_cc = 4
 
/*******************************************/
/* RELEASE LIBRARIES                       */
/*******************************************/
return_code = 0
"LMFREE DATAID("examrpt")"
lmfree_examrpt_rc = return_code
/*******************************************/
/* Update dataset directory ?              */
/*******************************************/
"LMFREE DATAID("temp1")"
"LMFREE DATAID("temp2")"
"LMINIT DATAID(TEMP1) DDNAME(TEMP1)"
"LMINIT DATAID(TEMP2) DDNAME(TEMP2)"
/*******************************************/
/* OPEN DATASETS                           */
/*******************************************/
return_code = 0
"LMOPEN DATAID("cntlid") OPTION(INPUT)"
lmopen_cntl_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN CNTL    RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
"LMOPEN DATAID("temp1") OPTION(INPUT)"  /* OPEN TEMP */
lmopen_temp1_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN TEMP1    RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
"LMOPEN DATAID("temp2") OPTION(INPUT)"  /* OPEN TEMP */
lmopen_temp2_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN TEMP2    RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
"LMOPEN DATAID("temp3") OPTION(OUTPUT)"  /* OPEN TEMP3 */
lmopen_temp3_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN TEMP3    RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
/*******************************************/
/* Save variables                          */
/*******************************************/
return_code = 0
"VPUT (TEMP1 TEMP2 TEMP3) ASIS"
vput_dataid_rc = return_code
If return_code > 4 then do
  Say pgmname "VPUT TEMP IDS   RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
/*******************************************/
/* Get MEMBER group identifiers            */
/*******************************************/
return_code = 0
/* Check dataset concatenation for table CACT0000*/
"LMMFIND DATAID("cntlid") MEMBER("cact0000")"
If return_code <> 0 then do
  Say pgmname "LMMFIND CNTL failed for MEMBER="cact0000 zerrsm
  return_code = 8
  end
Else do
  return_code = 0
  "VIEW DATAID("cntlid") MACRO("cacm000t") MEMBER("cact0000")"
  end
view_cact0000_rc = return_code
If return_code > 4 then do
  Say pgmname "VIEW CNTL" cact0000 "RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
"VGET (TBLMBR) ASIS"
/*tblmbr = tblmbr"#"*/
tblmbr = tblmbr
/*******************************************/
/* PUT DSNLST TO TEMP3                     */
/*******************************************/
return_code = 0
locate = sysdsn("'"temp2dsn"(DSNLIST)'")
If locate <> "OK" then do
  Say pgmname "DSN="temp2dsn "MEMBER=DSNLIST" locate
  return_code = 8
  end
Else do
  return_code = 0
  If typerun <> "SRRAUDIT" then
    "EDIT DATAID("temp2") MACRO("cacm1001") MEMBER(DSNLIST)"
  return_code = 0
  "VIEW DATAID("temp2") MACRO("cacm0405") MEMBER(DSNLIST)"
  end
view_dsnlist_rc = return_code
If return_code > 4 then do
  Say pgmname "VIEW TEMP2 DSNLIST   RC =" return_code strip(zerrsm)
  end
 
return_code = 0
 
/*******************************************/
/* EDIT EXAMINE MEMBERS                    */
/*******************************************/
/*******************************************/
/* INITIALIZE VARIABLES FOR EDIT MACRO     */
/*******************************************/
fcmd = "'   ' 1"                  /* FIND THREE SPACES IN COL 1      */
sck = 4                           /* SORT CHECK VARIABLE             */
sortpos = " "                     /* SORT POSITIONS                  */
mbrrpt = "APFXRPT"
Call find_iter
return_code = 0
"VPUT (FCMD ITER SCK SORTPOS) ASIS"
 
vput_apfxrpt_rc = return_code
If return_code <> 0 then do
  Say pgmname "VPUT APFXRPT  RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = 0
 
edit_apfxrpt_rc = editmbr(temp1,mbrrpt)
apflibs_cm01vget = cm01vget
apflibs_cm01ster = cm01ster
apflibs_cm01fer  = cm01fer
apflibs_cm01lper = cm01lper
 
fcmd = "'   ' 1"                  /* FIND THREE SPACES IN COL 1      */
sck = 4                           /* SORT CHECK VARIABLE             */
sortpos = " "                     /* SORT POSITIONS                  */
mbrrpt = "LNKXRPT"
Call find_iter
return_code = 0
"VPUT (FCMD ITER SCK SORTPOS) ASIS"
 
vput_lnkxrpt_rc = return_code
If return_code <> 0 then do
  Say pgmname "VPUT LNKXRPT  RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = 0
 
edit_lnkxrpt_rc = editmbr(temp1,mbrrpt)
linklibs_cm01vget = cm01vget
linklibs_cm01ster = cm01ster
linklibs_cm01fer  = cm01fer
linklibs_cm01lper = cm01lper
 
fcmd = "'   ' 1"                  /* FIND THREE SPACES IN COL 1      */
sck = 4                           /* SORT CHECK VARIABLE             */
sortpos = " "                     /* SORT POSITIONS                  */
mbrrpt = "LPAXRPT"
Call find_iter
return_code = 0
"VPUT (FCMD ITER SCK SORTPOS) ASIS"
 
vput_lpaxrpt_rc = return_code
If return_code <> 0 then do
  Say pgmname "VPUT LPAXRPT  RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = 0
 
edit_lpaxrpt_rc = editmbr(temp1,mbrrpt)
lpalibs_cm01vget = cm01vget
lpalibs_cm01ster = cm01ster
lpalibs_cm01fer  = cm01fer
lpalibs_cm01lper = cm01lper
 
fcmd = "'   ' 1"                  /* FIND THREE SPACES IN COL 1      */
sck = 37                          /* SORT CHECK VARIABLE             */
sortpos = "1 3 A 36 80 A"         /* SORT POSITIONS                  */
mbrrpt = "PPTXRPT"
Call find_iter
return_code = 0
"VPUT (FCMD ITER SCK SORTPOS) ASIS"
 
vput_pptxrpt_rc = return_code
If return_code <> 0 then do
  Say pgmname "VPUT PPTXRPT  RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = 0
 
edit_pptxrpt_rc = editmbr(temp1,mbrrpt)
ppt_cm01vget = cm01vget
ppt_cm01ster = cm01ster
ppt_cm01fer  = cm01fer
ppt_cm01lper = cm01lper
 
fcmd = "'LIBRARY NAME:' 2"        /* FIND LIBRARY NAME IN COL 2      */
sck = 20                          /* SORT CHECK VARIABLE             */
sortpos = "1 70 A"                /* SORT POSITIONS                  */
mbrrpt = "MVSXRPT"
Call find_iter
return_code = 0
"VPUT (FCMD ITER SCK SORTPOS) ASIS"
 
vput_mvsxrpt_rc = return_code
If return_code <> 0 then do
  Say pgmname "VPUT MVSXRPT  RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = 0
 
edit_mvsxrpt_rc = editmbr(temp1,mbrrpt)
mvsexits_cm01vget = cm01vget
mvsexits_cm01ster = cm01ster
mvsexits_cm01fer  = cm01fer
mvsexits_cm01lper = cm01lper
 
fcmd = "'LIBRARY:' 6"             /* FIND LIBRARY IN COL 6           */
sck = 15                          /* SORT CHECK VARIABLE             */
sortpos = "1 70 A"                /* SORT POSITIONS                  */
mbrrpt = "MVSXRPT"
/*Call find_iter*/
return_code = 0
"VPUT (FCMD ITER SCK SORTPOS) ASIS"
 
vput_mvsxrpt1_rc = return_code
If return_code <> 0 then do
  Say pgmname "VPUT MVSXRPT1  RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = 0
 
edit_mvsxrpt1_rc = editmbr(temp1,mbrrpt)
mvsexits1_cm01vget = cm01vget
mvsexits1_cm01ster = cm01ster
mvsexits1_cm01fer  = cm01fer
mvsexits1_cm01lper = cm01lper
 
fcmd = "'    ' 1"                  /* FIND FOUR SPACE IN COL 1        */
sck = 5                            /* SORT CHECK VARIABLE             */
sortpos = "1 50 A"                 /* SORT POSITIONS                  */
mbrrpt = "SMFXRPT"
Call find_iter
return_code = 0
"VPUT (FCMD ITER SCK SORTPOS) ASIS"
 
vput_smfxrpt_rc = return_code
If return_code <> 0 then do
  Say pgmname "VPUT SMFXRPT  RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = 0
 
edit_smfxrpt_rc = editmbr(temp1,mbrrpt)
smffiles_cm01vget = cm01vget
smffiles_cm01ster = cm01ster
smffiles_cm01fer  = cm01fer
smffiles_cm01lper = cm01lper
 
fcmd = "'ICF' 12"                 /* FIND ICF IN COL 12              */
sck = 29                          /* SORT CHECK VARIABLE             */
sortpos = "12 15 A 29 81 A"       /* SORT POSITIONS                  */
mbrrpt = "CATURPT"
Call find_iter
return_code = 0
"VPUT (FCMD ITER SCK SORTPOS) ASIS"
 
vput_catxrpt_rc = return_code
If return_code <> 0 then do
  Say pgmname "VPUT CATXRPT  RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = 0
 
edit_catxrpt_rc = editmbr(temp1,mbrrpt)
catalogs_cm01vget = cm01vget
catalogs_cm01ster = cm01ster
catalogs_cm01fer  = cm01fer
catalogs_cm01lper = cm01lper
 
fcmd = "'SMP/E CSI' 49"           /* FIND SMP/E CSI IN COL 49        */
sck = 4                           /* SORT CHECK VARIABLE             */
sortpos = "1 50 A"                /* SORT POSITIONS                  */
mbrrpt = "SMPERPT"
Call find_iter
return_code = 0
"VPUT (FCMD ITER SCK SORTPOS) ASIS"
 
vput_smperpt_rc = return_code
If return_code <> 0 then do
  Say pgmname "VPUT SMPERPT  RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = 0
 
edit_smperpt_rc = editmbr(temp1,mbrrpt)
smpecsi_cm01vget = cm01vget
smpecsi_cm01ster = cm01ster
smpecsi_cm01fer  = cm01fer
smpecsi_cm01lper = cm01lper
 
return_code = 0
mbrrpt = "JES2RPT"
Call find_iter
return_code = 0
"VPUT (ITER) ASIS"
 
vput_jes2_rc = return_code
If return_code <> 0 then do
  Say pgmname "VPUT JES2     RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
jes2parm = " "
jes2cnt = 0
return_code = 0
locate = sysdsn("'"temp1dsn"(JES2PARM)'")
If locate <> "OK" then do
  Say pgmname "DSN="temp1dsn "MEMBER=JES2PARM" locate
  return_code = 8
  end
Else do
  "VIEW DATAID("temp1") MACRO("cacm0403") MEMBER(JES2PARM)"
  return_code = 0
  end
view_jes2_rc = return_code
/*******************************************/
/* INIT JES2 PARMS LIBRARY                 */
/*******************************************/
return_code = 0
"VGET (JES2PARM JES2CNT) ASIS"
jes2parm = jes2parm
jes2cnt = jes2cnt
If jes2cnt = 0 | jes2parm = " " then do
  Say ">=========================================================<"
  Say ">==  EXAM.RPT(JES2PARM) HAS NO DATASETS SPECIFIED       ==<"
  Say ">=========================================================<"
  exit_cc = 8
  end
 
lminit_syslib3_rc = "n/a"
lmfree_syslib3_rc = "n/a"
lmclose_temp2_rc = "n/a"
lmopen2_temp2_rc = "n/a"
lmcopy_jes2_rc = "n/a"
view_jescrpt_rc = "n/a"
do while jes2parm <> ""
  parse var jes2parm jes2info jes2parm
  return_code = 0
  parse var jes2info jesdsn"("jesprm")"
  ac = substr(iter||jesdsn||blk44,1,50)
  ac = ac||pgmname
  return_code = 0
  "LMPUT DATAID("temp3") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") NOBSCAN"
  If return_code <> 0 then
    Say pgmname "LMPUT1 TEMP3" return_code zerrsm
  If jesdsn = " " | jesprm = " " then
    leave
  return_code = 0
  "LMINIT DATAID(SYSLIB3) DATASET('"jesdsn"')"
  lminit_syslib3_rc = return_code
  If return_code <> 0 then
    leave
/*******************************************/
/* CLOSE TEMP2                             */
/*******************************************/
  return_code = 0
  "LMCLOSE DATAID("temp2")"
  lmclose_temp2_rc = return_code
/*******************************************/
/* COPY JES2PARMS                          */
/*******************************************/
  return_code = 0
  "LMCOPY FROMID("syslib3") FROMMEM("jesprm") TODATAID("temp2")",
    "TOMEM("jesprm") REPLACE"
  lmcopy_jes2_rc = return_code
 
  If return_code <> 0 then do
    Say pgmname "LMCOPY" jesprm  "RC =" return_code strip(zerrsm)
    Say pgmname "From" jesdsn    "to" temp2dsn
    leave
    end
/*******************************************/
/* OPEN  TEMP2                             */
/*******************************************/
  return_code = 0
  "LMOPEN DATAID("temp2") OPTION(OUTPUT)"  /* OPEN TEMP */
  lmopen2_temp2_rc = return_code
  If return_code <> 0 then
    leave
/*******************************************/
/* FREE SYSLIB3                            */
/*******************************************/
  return_code = 0
  "LMFREE DATAID("syslib3")"
  lmfree_syslib3_rc = return_code
/*******************************************/
/* CALL JES2 MACRO                         */
/*******************************************/
  return_code = 0
  locate = sysdsn("'"temp2dsn"("jesprm")'")
  If locate <> "OK" then do
    Say pgmname "DSN="temp2dsn "MEMBER="jesprm locate
    return_code = 8
    end
  Else do
    return_code = 0
    "VIEW DATAID("temp2") MACRO("cacm0404") MEMBER("jesprm")"
    end
  view_jescrpt_rc = return_code
  end
/*******************************************/
/* Get STC group identifiers               */
/*******************************************/
return_code = 0
locate = sysdsn("'"temp2dsn"("stclist")'")
If locate <> "OK"then do
  Say pgmname "DSN="temp2dsn "MEMBER="stclist locate
  return_code = 8
  end
Else do
  return_code = 0
  "VIEW DATAID("temp2") MACRO("cacm000t") MEMBER("stclist")"
  end
view_stclist_rc = return_code
view_grslist_rc = "n/a"
If return_code <= 4 then do
  "VGET (TBLSTC) ASIS"
  locate = sysdsn("'"temp2dsn"("grslist")'")
  If locate <> "OK" then do
    Say pgmname "DSN="temp2dsn "MEMBER="grslist locate
    return_code = 8
    end
  Else do
    return_code = 0
    "VIEW DATAID("temp2") MACRO("cacm0421") MEMBER("grslist")"
    end
  view_grslist_rc = return_code
  end
 
/*******************************************/
/* CLOSE TEMP3                             */
/*******************************************/
CLOSE_TEMP3:
return_code = 0
"LMCLOSE DATAID("temp3")"
lmclose_temp3_rc = return_code
/*******************************************/
/* EDIT DSNLIST    TEMP3                   */
/*******************************************/
return_code = 0
"LMOPEN DATAID("temp3") OPTION(INPUT)"
lmopen2_temp3_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN-2 TEMP3     RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
DUPELIM:
return_code = 0
If dupsby = "DSN" then
  sortpos = 4" 50 A 1 3 A 51 58 A"  /* SORT BY DSN GROUP */
Else
  sortpos = 1" 58 A"                /* SORT BY GROUP DSN */
return_code = 0
"VPUT (FCMD SCK SORTPOS) ASIS"
 
vput_temp3_rc = return_code
If return_code <> 0 then do
  Say pgmname "VPUT TEMP3    RC =" return_code strip(zerrsm)
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
return_code = 0
"EDIT DATAID("temp3") MACRO("cacm0406")"
edit_temp3_rc = return_code
If return_code > 4 then do
  Say pgmname "EDIT TEMP3         RC =" return_code strip(zerrsm)
  end
/*******************************************/
/* CLOSE OUTPUT                            */
/*******************************************/
END_EXIT:
return_code = 0
"LMCLOSE DATAID("cntlid")"
lmclose_cntl_rc = return_code
return_code = 0
"LMCLOSE DATAID("temp1")"
lmclose_temp1_rc = return_code
return_code = 0
"LMCLOSE DATAID("temp2")"
lmclose3_temp2_rc = return_code
return_code = 0
"LMCLOSE DATAID("temp3")"
lmclose2_temp3_rc = return_code
/*******************************************/
/* FREE FILES                              */
/*******************************************/
return_code = 0
"LMFREE DATAID("cntlid")"
lmfree_cntl_rc = return_code
return_code = 0
"LMFREE DATAID("temp1")"
lmfree_temp1_rc = return_code
return_code = 0
"LMFREE DATAID("temp2")"
lmfree_temp2_rc = return_code
return_code = 0
"LMFREE DATAID("temp3")"
lmfree_temp3_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 (CM03VGET CM03FE CM04VGET CM04FER CM04F2ER CM05VGET",
  "CM05LPER CM06VGET CM06SE CM06S2E CM006RC) ASIS"
return_code = 0
 
If termmsgs = "ON" then do
  Say "==============================================================="
  Say pgmname "LMINIT_EXAMRPT_RC         "lminit_examrpt_rc
  Say pgmname "LMINIT_CNTL_RC            "lminit_cntl_rc
  Say pgmname "LMINIT_TEMP1_RC           "lminit_temp1_rc
  Say pgmname "LMINIT_TEMP2_RC           "lminit_temp2_rc
  Say pgmname "LMINIT_TEMP3_RC           "lminit_temp3_rc
  Say pgmname "LMCOPY_DSNLIST_RC         "lmcopy_dsnlist_rc
  Say pgmname "LMCOPY_STCLIST_RC         "lmcopy_stclist_rc
  Say pgmname "LMCOPY_APFXRPT_RC         "lmcopy_apfxrpt_rc
  Say pgmname "LMCOPY_LNKXRPT_RC         "lmcopy_lnkxrpt_rc
  Say pgmname "LMCOPY_LPAXRPT_RC         "lmcopy_lpaxrpt_rc
  Say pgmname "LMCOPY_PPTXRPT_RC         "lmcopy_pptxrpt_rc
  Say pgmname "LMCOPY_MVSXRPT_RC         "lmcopy_mvsxrpt_rc
  Say pgmname "LMCOPY_SMFXRPT_RC         "lmcopy_smfxrpt_rc
  Say pgmname "LMCOPY_CATXRPT_RC         "lmcopy_catxrpt_rc
  Say pgmname "LMCOPY_SMPERPT_RC         "lmcopy_smperpt_rc
  Say pgmname "LMCOPY_JES2EXAM_RC        "lmcopy_jes2exam_rc
  Say pgmname "LMOPEN_CNTL_RC            "lmopen_cntl_rc
  Say pgmname "LMOPEN_TEMP1_RC           "lmopen_temp1_rc
  Say pgmname "LMOPEN_TEMP2_RC           "lmopen_temp2_rc
  Say pgmname "LMOPEN_TEMP3_RC           "lmopen_temp3_rc
  Say pgmname "VPUT_DATAID_RC            "vput_dataid_rc
  Say "==============================================================="
 
  Say pgmname "COPY" dsnlist
  Say "==============================================================="
 
  Say pgmname "VIEW_CACT0000_RC          "view_cact0000_rc
  Say pgmname "VIEW_DSNLIST_RC           "view_dsnlist_rc
  If view_dsnlist_rc <> 0 then do
    Say pgmname cacm0405 "VGET       "cm05vget
    Say pgmname cacm0405 "LPER       "cm05lper
    end
  Say "==============================================================="
 
  Say "APFLIBS"
  Say "==============================================================="
 
  Say pgmname "VPUT_APFXRPT_RC           "vput_apfxrpt_rc
  Say pgmname "EDIT_APFXRPT_RC           "edit_apfxrpt_rc
  If edit_apfxrpt_rc <> 0 then do
    Say pgmname cacm0401 "VGET       "apflibs_cm01vget
    Say pgmname cacm0401 "STER       "apflibs_cm01ster
    Say pgmname cacm0401 "FER        "apflibs_cm01fer
    Say pgmname cacm0401 "LPER       "apflibs_cm01lper
    end
  Say "==============================================================="
 
  Say "LINKLIBS"
  Say "==============================================================="
 
  Say pgmname "VPUT_LNKXRPT_RC           "vput_lnkxrpt_rc
  Say pgmname "EDIT_LNKXRPT_RC           "edit_lnkxrpt_rc
  If edit_lnkxrpt_rc <> 0 then do
    Say pgmname cacm0401 "VGET       "linklibs_cm01vget
    Say pgmname cacm0401 "STER       "linklibs_cm01ster
    Say pgmname cacm0401 "FER        "linklibs_cm01fer
    Say pgmname cacm0401 "LPER       "linklibs_cm01lper
    end
  Say "==============================================================="
 
  Say "LPALIBS"
  Say "==============================================================="
 
  Say pgmname "VPUT_LPAXRPT_RC           "vput_lpaxrpt_rc
  Say pgmname "EDIT_LPAXRPT_RC           "edit_lpaxrpt_rc
  If edit_lpaxrpt_rc <> 0 then do
    Say pgmname cacm0401 "VGET       "lpalibs_cm01vget
    Say pgmname cacm0401 "STER       "lpalibs_cm01ster
    Say pgmname cacm0401 "FER        "lpalibs_cm01fer
    Say pgmname cacm0401 "LPER       "lpalibs_cm01lper
    end
  Say "==============================================================="
 
  Say "PPT"
  Say "==============================================================="
 
  Say pgmname "VPUT_PPTXRPT_RC           "vput_pptxrpt_rc
  Say pgmname "EDIT_PPTXRPT_RC           "edit_pptxrpt_rc
  If edit_pptxrpt_rc <> 0 then do
    Say pgmname cacm0401 "VGET       "ppt_cm01vget
    Say pgmname cacm0401 "STER       "ppt_cm01ster
    Say pgmname cacm0401 "FER        "ppt_cm01fer
    Say pgmname cacm0401 "LPER       "ppt_cm01lper
    end
  Say "==============================================================="
 
  Say "MVSEXITS"
  Say "==============================================================="
 
  Say pgmname "VPUT_MVSXRPT_RC           "vput_mvsxrpt_rc
  Say pgmname "EDIT_MVSXRPT_RC           "edit_mvsxrpt_rc
  If edit_mvsxrpt_rc <> 0 then do
    Say pgmname cacm0401 "VGET       "mvsexits_cm01vget
    Say pgmname cacm0401 "STER       "mvsexits_cm01ster
    Say pgmname cacm0401 "FER        "mvsexits_cm01fer
    Say pgmname cacm0401 "LPER       "mvsexits_cm01lper
    end
  Say "==============================================================="
 
  Say "MVSEXITS DYNAMIC EXIT"
  Say "==============================================================="
 
  Say pgmname "VPUT_MVSXRPT_RC           "vput_mvsxrpt1_rc
  Say pgmname "EDIT_MVSXRPT_RC           "edit_mvsxrpt1_rc
  If edit_mvsxrpt1_rc <> 0 then do
    Say pgmname cacm0401 "VGET       "mvsexits1_cm01vget
    Say pgmname cacm0401 "STER       "mvsexits1_cm01ster
    Say pgmname cacm0401 "FER        "mvsexits1_cm01fer
    Say pgmname cacm0401 "LPER       "mvsexits1_cm01lper
    end
  Say "==============================================================="
 
  Say "SMFFILES"
  Say "==============================================================="
 
  Say pgmname "VPUT_SMFXRPT_RC           "vput_smfxrpt_rc
  Say pgmname "EDIT_SMFXRPT_RC           "edit_smfxrpt_rc
  If edit_smfxrpt_rc <> 0 then do
    Say pgmname cacm0401 "VGET       "smffiles_cm01vget
    Say pgmname cacm0401 "STER       "smffiles_cm01ster
    Say pgmname cacm0401 "FER        "smffiles_cm01fer
    Say pgmname cacm0401 "LPER       "smffiles_cm01lper
    end
  Say "=============================================================="
  Say "CATALOGS"
  Say "=============================================================="
  Say pgmname "VPUT_CATXRPT_RC           "vput_catxrpt_rc
  Say pgmname "EDIT_CATXRPT_RC           "edit_catxrpt_rc
  If edit_catxrpt_rc <> 0 then do
    Say pgmname cacm0401 "VGET       "catalogs_cm01vget
    Say pgmname cacm0401 "STER       "catalogs_cm01ster
    Say pgmname cacm0401 "FER        "catalogs_cm01fer
    Say pgmname cacm0401 "LPER       "catalogs_cm01lper
    end
  Say "==============================================================="
 
  Say "SMP/E"
  Say "==============================================================="
 
  Say pgmname "VPUT_SMPERPT_RC           "vput_smperpt_rc
  Say pgmname "EDIT_SMPERPT_RC           "edit_smperpt_rc
  If edit_smperpt_rc <> 0 then do
    Say pgmname cacm0401 "VGET       "smpecsi_cm01vget
    Say pgmname cacm0401 "STER       "smpecsi_cm01ster
    Say pgmname cacm0401 "FER        "smpecsi_cm01fer
    Say pgmname cacm0401 "LPER       "smpecsi_cm01lper
    end
  Say "==============================================================="
 
  Say "JES2 LIBS FROM EXAMINE"
  Say "==============================================================="
 
  Say pgmname "VPUT_JES2_RC              "vput_jes2_rc
  Say pgmname "VIEW_JES2_RC              "view_jes2_rc
  If view_jes2_rc <> 0 then do
    Say pgmname cacm0403 "VGET       "cm03vget
    Say pgmname cacm0403 "FE         "cm03fe
    end
  Say "==============================================================="
 
  Say pgmname "LMINIT_SYSLIB3_RC         "lminit_syslib3_rc
  Say pgmname "LMCLOSE_TEMP2_RC          "lmclose_temp2_rc
  Say pgmname "LMCOPY_JES2_RC            "lmcopy_jes2_rc
  Say pgmname "LMOPEN2_TEMP2_RC          "lmopen2_temp2_rc
  Say pgmname "LMFREE_SYSLIB3_RC         "lmfree_syslib3_rc
  Say "==============================================================="
 
  Say "JES2 DATASETS FROM JES2 PARMS"
  Say "==============================================================="
 
  Say pgmname "VIEW_JESCRPT_RC           "view_jescrpt_rc
  If view_jescrpt_rc <> 0 &,
     datatype(view_jescrpt_rc) = "NUM" then do
    Say pgmname cacm0404 "VGET       "cm04vget
    Say pgmname cacm0404 "FER        "cm04fer
    Say pgmname cacm0404 "F2ER       "cm04f2er
    end
  Say "==============================================================="
 
  Say pgmname "VIEW_STCLIST_RC           "view_stclist_rc
  Say pgmname "VIEW_GRSLIST_RC           "view_grslist_rc
  Say pgmname "LMCLOSE_TEMP3_RC          "lmclose_temp3_rc
  Say pgmname "LMOPEN2_TEMP3_RC          "lmopen2_temp3_rc
  Say "==============================================================="
 
  Say "DUP/ELIM OF TEMP3"
  Say "==============================================================="
 
  Say pgmname "VPUT_TEMP3_RC             "vput_temp3_rc
  Say pgmname "EDIT_TEMP3_RC             "edit_temp3_rc
  Say pgmname cacm0406 "CM006RC          "cm006rc
  If cm006rc <> 0 then do
    Say pgmname cacm0406 "VGET       "cm06vget
    Say pgmname cacm0406 "SORT RC    "cm06se
    Say pgmname cacm0406 "SORT2 RC   "cm06s2e
    end
  Say "==============================================================="
 
  Say pgmname "LMCLOSE_CNTL_RC           "lmclose_cntl_rc
  Say pgmname "LMCLOSE_TEMP1_RC          "lmclose_temp1_rc
  Say pgmname "LMCLOSE3_TEMP2_RC         "lmclose3_temp2_rc
  Say pgmname "LMCLOSE2_TEMP3_RC         "lmclose2_temp3_rc
  Say pgmname "LMFREE_CNTL_RC            "lmfree_cntl_rc
  Say pgmname "LMFREE_TEMP1_RC           "lmfree_temp1_rc
  Say pgmname "LMFREE_TEMP2_RC           "lmfree_temp2_rc
  Say pgmname "LMFREE_TEMP3_RC           "lmfree_temp3_rc
  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':' ERRORTEXT(rc)
  say SOURCELINE(sigl)
  end
if return_code > maxcc then
  maxcc = return_code
return
 
 
FIND_ITER:
/*********************************************************************/
/* Find MBRRPT in TBLMBR and extract additional fields               */
/*********************************************************************/
ITER    = "99 "
TITLE   =
PDI     =
x = 0
do forever
  if x = 0 then x = wordpos(MBRRPT,TBLMBR)
  else x = wordpos(MBRRPT,TBLMBR,x)
  if x = 0 then leave
  y = wordindex(TBLMBR,x)-4
  if substr(TBLMBR,y,1) = "#" then do
    TBLENT = substr(TBLMBR,y)
    parse var TBLENT . 2 ITER 5 . 14 PDI 23 TITLE "#" .
    leave
  end
end
 
if TITLE <> ' ' then do
  x = index(TITLE,'@')
  TITLE   = substr(TITLE,1,x-1)
end
 
cm01vget = "n/a"
cm01ster = "n/a"
cm01fer  = "n/a"
cm01lper = "n/a"
"VPUT (CM01VGET CM01STER CM01FER CM01LPER) ASIS"
Return (0)
 
 
copymbr:
return_code = 0
if arg(4) = "" then
  tombr = arg(2)
else
  tombr = arg(4)
"LMCOPY FROMID("arg(1)") FROMMEM("arg(2)")",
  "TODATAID("arg(3)") TOMEM("tombr") REPLACE"
 
If return_code <> 0 then do
  Say ">=========================================================<"
  if arg(5) = "c" then do
    Say ">==  CNTL("arg(2)") is missing" strip(zerrsm)          "==<"
    Say pgmname "From" cntldsn       "to" temp2dsn
    end
  else do
    Say ">==  EXAM.RPT("arg(2)") is missing" strip(zerrsm)        "==<"
    Say pgmname "From" examdsn       "to" temp1dsn
    end
  Say ">=========================================================<"
  end
Return return_code
 
 
editmbr:
return_code = 0
locate = sysdsn("'"temp1dsn"("mbrrpt")'")
If locate <> "OK" then do
  Say pgmname "DSN="temp1dsn "MEMBER="mbrrpt locate
  return_cc = 8
  End
Else do
  return_cc = 0
  "EDIT DATAID("temp1") MACRO("cacm0401") MEMBER("mbrrpt")"
  end
edit_apfxrpt_rc = return_code
"VGET (CM01VGET CM01STER CM01FER CM01LPER) ASIS"
Return return_cc
