/* REXX */
/* CLS2REXXed by FSOX001 on 11 Jul 2016 at 15:28:46  */
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
Address ISREDIT
 
"MACRO"            /* CACM0405 EDIT TEMP2(DSNLIST) OR (CA?ILIST) */
/*********************************************************************/
/* 06/04/2004 JL.NELSON CHANGED TO COLLECT NEW FINDINGS              */
/* 06/15/2004 JL.NELSON ADDED EXIT CODE                              */
/* 08/25/2004 JL.NELSON ADDED code to include sys?.iplparm libraries */
/* 10/26/2004 JL.NELSON ADDED TBLMBR for dataset group identifer     */
/* 12/02/2004 JL.NELSON CHANGED FOR ALL FIELDS IN TBLMBR             */
/* 02/14/2005 JL.NELSON Changed constants to variables before rename */
/* 03/16/2005 JL.NELSON Correct length error code 864                */
/* 03/22/2005 JL.NELSON Changed to use old table and DSNLIST         */
/* 04/06/2005 JL.NELSON Added code for master catalog ACP00130       */
/* 06/09/2005 JL.NELSON Pass MAXCC in ZISPFRC variable               */
/* 06/15/2005 JL.NELSON Set return code to end job step              */
/* 03/03/2006 JL.NELSON Made changes to avoid SUBSTR abend 920/932.  */
/* 03/29/2006 JL.NELSON Test for empty member LINENUM Rcode = 4.     */
/* 04/17/2006 JL.NELSON Use NRSTR avoid abend 900 if ampersand in    */
/*            data.                                                  */
/* 06/02/2009 CL.FENTON Changes on how TBLMBR is processed.          */
/* 07/12/2016 CL.FENTON Converted script from CLIST to REXX.         */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CACM0005 07/12/16"
sysprompt = "OFF"                /* CONTROL NOPROMPT          */
sysflush = "OFF"                 /* CONTROL NOFLUSH           */
sysasis = "ON"                   /* CONTROL ASIS - caps off   */
/* *************************************** */
/* THIS IS A COPY MACRO                    */
/* *************************************** */
Address ISPEXEC "CONTROL NONDISPL ENTER"
Address ISPEXEC "CONTROL ERRORS RETURN"
/* *************************************** */
/* VARIABLES ARE PASSED TO THIS MACRO      */
/* CONSLIST                                */
/* COMLIST                                 */
/* SYMLIST                                 */
/* TERMMSGS                                */
/* *************************************** */
return_code = 0
Address ISPEXEC "VGET (CONSLIST COMLIST SYMLIST TERMMSGS TEMP1",
  "TEMP2 TEMP3 TBLMBR NUCLDSN) ASIS"
cm05vget = 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 "TEMP1/"temp1 "TEMP2/"temp2 "TEMP3/"temp3 "TBLMBR/"tblmbr,
    "NUCLDSN/"nucldsn
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
If CONSLIST = "ON" | COMLIST = "ON" | SYMLIST = "ON" ,
  then Trace r
 
maxcc = 0
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         */
/* *************************************** */
/* MAIN PROCESS                            */
/* *************************************** */
"(MEMBER) = MEMBER"
"(DSNAME) = DATASET"
return_code = 0
"(LASTLINE) = LINENUM .ZLAST"
If return_code > 0 then do
  If lastline = 0 then
    Say pgmname "Empty file RCode =" return_code "DSN="dsname,
      "MEMBER="member zerrsm
  else
    Say pgmname "LINENUM Error RCode =" return_code "DSN="dsname,
      "MEMBER="member  zerrsm
  SIGNAL ERR_EXIT
  end
blk44 = "                                            "
counter = 1
/* *************************************** */
/* COPY LOOP                               */
/* *************************************** */
do until counter > lastline
  return_code = 0
  "(DATA) = LINE" counter
 
  ac = data
/* *************************************** */
/* WRITE DATA TO TEMP3                     */
/* *************************************** */
  return_code = 0
  Address ISPEXEC "LMPUT DATAID("temp3") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") NOBSCAN"
  cm05lper = return_code
  If return_code > 4 then do
    Say pgmname "LMPUT TEMP3" return_code  zerrsm
    return_code = return_code + 16
    SIGNAL ERR_EXIT
    end
  counter = counter + 1
  end
/* *************************************** */
/* FIND IPLPARM LIBRARIES                  */
/* *************************************** */
IPL_PARM:
return_code = 0
mbrrpt = "PARMRPT"
Call find_iter
x = outtrap("msg.",1)
Do I = 0 to 9
  dsname = "SYS"i".IPLPARM"
  If sysdsn("'"dsname"'") = "OK" then do
    ac = substr(iter||dsname||blk44,1,50)
    ac = ac||pgmname
    return_code = 0
    Address ISPEXEC "LMPUT DATAID("temp3") MODE(INVAR) DATALOC(AC)",
      "DATALEN("length(ac)") NOBSCAN"
    If return_code <> 0 then
      Say pgmname "LMPUT2 TEMP3" return_code  zerrsm
    end
  end
x = outtrap("OFF")
/* *************************************** */
/* FIND MASTER CATALOG                     */
/* *************************************** */
mbrrpt = "CATMRPT"
Call find_iter
resdsn = " "
catdsn = " "
info. = ""
x = outtrap("info.")
Address TSO "LISTCAT ENTRIES('"nucldsn"')"
y = outtrap("OFF")
If pos("LISTCAT ENTRIES",info.1) = 0 then do
  resdsn = substr(info.1,17)
  catdsn = substr(info.2,17)
  end
Else do
  resdsn = substr(info.2,17)
  catdsn = substr(info.3,17)
  end
If nucldsn <> resdsn then do
  Say pgmname "NUCLDSN =" nucldsn  "RESDSN =" resdsn
/*SIGNAL END_EXIT*/
  end
Else ,
  If catdsn = " " then do
    Say pgmname "NUCLDSN =" nucldsn  "CATALOG name is blank or not found."
  /*SIGNAL END_EXIT*/
    end
if nucldsn = resdsn & catdsn <> " " then do
  ac = substr(iter||catdsn||blk44,1,50)
  ac = ac||pgmname
  return_code = 0
  Address ISPEXEC "LMPUT DATAID("temp3") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") NOBSCAN"
  If return_code <> 0 then
    Say pgmname "LMPUT3 TEMP3" return_code zerrsm
  end
/* *************************************** */
/* END PROCESSES                           */
/* *************************************** */
END_EXIT:
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
cm005rc = return_code
Address ISPEXEC "VPUT (CM05VGET CM05LPER CM005RC) ASIS"
"END"
"MEND"
Exit (0)
 
 
/* *************************************** */
/*  SYSCALL SUBROUTINES                    */
/* *************************************** */
 
 
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
 
Return (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
 
 
