/* REXX */
/* CLS2REXXed by FSOX001 on 19 Jun 2018 at 15:49:25  */
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
Address ISREDIT
 
"MACRO"               /* CACM0009 EDIT PARMLIB(IEAFIX* IEALPA*)*/
/*********************************************************************/
/* 06/15/2004 JL.NELSON ADDED EXIT CODE.                             */
/* 12/23/2004 JL.NELSON IKJ79075I System variable SYSSYMDEF failed   */
/*            RC=8.                                                  */
/* 01/25/2005 JL.NELSON Ignore comments in PARMLIB.                  */
/* 02/11/2005 JL.NELSON Changed constants to variables before        */
/*            rename.                                                */
/* 03/02/2005 JL.NELSON ADDED PDIERROR for return condition.         */
/* 03/09/2005 JL.NELSON Changed LMMREP to LMMADD/LMMREP to avoid     */
/*            errors.                                                */
/* 04/21/2005 JL.NELSON Added LPA message for new PDI.               */
/* 06/09/2005 JL.NELSON Pass MAXCC in ZISPFRC variable.              */
/* 06/15/2005 JL.NELSON Set return code to end job step.             */
/* 06/16/2005 JL.NELSON Changed to display the real LISTDSI error    */
/*            msg.                                                   */
/* 06/16/2005 JL.NELSON Modified to test sysreason for LISTDSI       */
/*            command.                                               */
/* 06/23/2005 JL.NELSON Modified for IEALPA LIBRARY(dsname)          */
/*            VOLUME(vol).                                           */
/* 09/26/2005 JL.NELSON SYSSYMDEF check to end with a period or      */
/*            ")".                                                   */
/* 10/17/2005 JL.NELSON IKJ79075I SYSSYMDEF rc=8 maxcc=624 length    */
/*            gt 8.                                                  */
/* 10/18/2005 JL.NELSON Added code to debug syssymdef errors.        */
/* 03/06/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/29/2006 JL.NELSON Test for empty member LINENUM Rcode = 4.     */
/* 04/11/2006 JL.NELSON Replace & with ? if varible length > 8.      */
/* 05/09/2006 JL.NELSON Avoid RC 20 on ISREDIT LINE when " or ' in   */
/*            data.                                                  */
/* 03/05/2007 CL.FENTON Added process for logical parmlibs.          */
/* 09/22/2009 CL.FENTON Added REMOVE_COMMENTS to remove comments     */
/*            from various member.  Modification made remove comment */
/*            logic from other parts of this member, also chgs to    */
/*            symbolic process.                                      */
/* 04/26/2011 CL.FENTON Corrected symbolic change by changing both   */
/*            %&NAME.. and %&NAME to &NAME2.                         */
/* 06/19/2018 CL.FENTON Converted script from CLIST to REXX.         */
/*            Also prevented IKJ56709I from being displayed when     */
/*            the LISTDSI function is issued.                        */
/* 04/08/2019 CL.FENTON Correct issue with LISTDSI by stripping      */
/*            spaces from dataset entries, STS-022062.               */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CACM0009 04/08/19"
sysprompt = "OFF"                /* CONTROL NOPROMPT          */
sysflush  = "OFF"                /* CONTROL NOFLUSH           */
sysasis   = "ON"                 /* CONTROL ASIS - caps off   */
/*******************************************/
/* VARIABLES ARE PASSED TO THIS MACRO      */
/* CONSLIST                                */
/* COMLIST                                 */
/* SYMLIST                                 */
/* TERMMSGS                                */
/*******************************************/
 
Address ISPEXEC "CONTROL NONDISPL ENTER"
Address ISPEXEC "CONTROL ERRORS RETURN"
return_code = 0
Address ISPEXEC "VGET (CONSLIST COMLIST SYMLIST TERMMSGS MBRMSG",
  "CACM040A TEMP8 MEMBER PARMDSN PDIDD PDINAME) ASIS"
cm09vget = 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 "MBRMSG/"mbrmsg "CACM040A/"cacm040a "TEMP8/"temp8,
    "MEMBER/"member
  Say pgmname "PDIDD/"pdidd "PDINAME/"pdiname
  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                            */
/*******************************************/
vmember = member
"(MEMBER) = MEMBER"
"(DSNAME) = DATASET"
"NUMBER = OFF"
"AUTONUM = OFF"
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
bc = "/*"
modify = ""
Address TSO "PROFILE NOPREFIX"
lp = "("
rp = ")"
row = 1
col = 0
 
 
PRE_LOOP:
"CHANGE ALL X'50' X'6C'"         /* CHANGE ALL '&' '%' */
do forever
  return_code = 0
  "CURSOR =" row col
  "FIND X'6C'"     /* FIND '%' */
 
  If return_code > 0 then leave
 
  "(ROW,COL) = CURSOR"
  "(DATA) = LINE" row
  strt = col + 1
  endx = length(data)
  end1 = pos(" ",data,col)-1
 
  parse var data =(strt) temp .
  If temp = "" then iterate
 
  x = pos(".",temp)
  If x > 2 then
    parse var temp temp "."
  x = pos(",",temp)
  If x > 2 then,
    parse var temp temp ","
  x = pos("'",temp)
  If x > 2 then,
    parse var temp temp "'"
  x = pos('"',temp)
  If x > 2 then
    parse var temp temp '"'
  x = pos("%",temp)
  If x > 2 then
    parse var temp temp "%"
  x = pos(lp,temp)
  If x > 2 then
    parse var temp temp (lp) .
  x = pos(rp,temp)
  If x > 2 then
    parse var temp temp (rp) .
  If temp <> "" then do
    name = strip(temp,"b")
    return_code = 0
    save_maxcc = maxcc
    name2 = mvsvar('SYMDEF',name)
    If return_code > 4 then do
      Say pgmname member "NAME =" name "DATA =" data
      maxcc = save_maxcc
      end
    If return_code = 0 & name2 <> " " then do
      "CHANGE ALL '%"name".' '"name2"'"
      "CHANGE ALL '%"name"' '"name2"'"
      end
    end
  end
"CHANGE ALL X'6C' X'50'"         /* CHANGE ALL '%' '&' */
NEXT_1:
return_code = 0
counter = 0
nr = 0
src. = ""
 
 
MAIN:
do counter = 1 to lastline
  return_code = 0
  "(DATA) = LINE" counter
  parse var data data "/*" .
  If substr(data,1,1) = "*" then iterate
  If data = " " then iterate
  data = strip(data,"b")
  If pos("INCLUDE ",data) > 0 then do
    nr = nr + 1
    src.nr = data
    iterate
    end
  src.nr = src.nr data
  end
src.0 = nr
do x = 1 to src.0
  parse var src.x . "LIBRARY(" dataset ")" .
  parse var src.x . "VOLUME(" vol ")" .
  If dataset = " " then iterate
  dataset = strip(dataset,"B")
 
 
LIST_DATA:
  return_code = 0
  If pos("/",dataset) > 0 then iterate
  msg = msg('OFF')
  If vol <> " " then,
    lst = listdsi("'"dataset"'" "VOLUME("vol")")
  Else,
    lst = listdsi("'"dataset"'")
  msg = msg(msg)
  If sysreason = 0 then iterate
  vol = left(vol,6)
  dataset = left(dataset,44)
  If mbrmsg = "ON" then,
    Say pgmname member "Dsn="dataset "Vol="vol "Sr="sysreason
  reason = sysmsglvl2
  If sysreason = 1 & pos("&",dataset) > 0 then do
    reason = "IKJ58401I INVALID DATASET NAME, SYMDEF not defined",
      "or is invalid"
    end
  If sysreason = 24 & vol <> " " then
      reason = "IKJ58424I DATA SET NOT FOUND ON VOLUME" vol
  If sysreason > 0 then do
    If modify <> "YES" then do
      ac = "The following non-existent inaccessible LPA",
        "library(ies) were found:"
      return_code = 0
      Address ISPEXEC "LMPUT DATAID("temp8") MODE(INVAR) DATALOC(AC)",
        "DATALEN("length(ac)") MEMBER("vmember")"
      If return_code <> 0 then do
        Say pgmname "LMPUT TEMP8" vmember "RC =" return_code zerrsmm
        return_code = return_code + 16
        SIGNAL ERR_EXIT
        end
      ac = " "
      return_code = 0
      Address ISPEXEC "LMPUT DATAID("temp8") MODE(INVAR) DATALOC(AC)",
        "DATALEN("length(ac)") MEMBER("vmember")"
      If return_code <> 0 then do
        Say pgmname "LMPUT TEMP8" vmember "RC =" return_code zerrsm
        return_code = return_code + 16
        SIGNAL ERR_EXIT
        end
      ac = "     "parmdsn"("vmember")"
      return_code = 0
      Address ISPEXEC "LMPUT DATAID("temp8") MODE(INVAR) DATALOC(AC)",
        "DATALEN("length(ac)") MEMBER("vmember")"
      If return_code <> 0 then do
        Say pgmname "LMPUT TEMP8" vmember "RC =" return_code zerrsm
        return_code = return_code + 16
        SIGNAL ERR_EXIT
        end
      end
    ac = "          "dataset" "vol" "reason
    return_code = 0
    Address ISPEXEC "LMPUT DATAID("temp8") MODE(INVAR) DATALOC(AC)",
      "DATALEN("length(ac)") MEMBER("vmember")"
    If return_code <> 0 then do
      Say pgmname "LMPUT TEMP8" vmember "RC =" return_code zerrsm
      return_code = return_code + 16
      SIGNAL ERR_EXIT
      end
    modify = "YES"
    pdierror = 8
    If pdiname <> " " then do
      Address ISPEXEC "VPUT (AC PDIERROR) ASIS"
      return_code = 0
      Address ISPEXEC "EDIT DATAID("pdidd") MACRO("cacm040a")",
        "MEMBER("pdiname")"
      If return_code > 4 then do
        Say pgmname "EDIT PDI" pdiname  "RC =" return_code zerrsm
        return_code = return_code + 16
        SIGNAL ERR_EXIT
        end
      end
    end
  end
 
/*******************************************/
/* END PROCESSES                           */
/*******************************************/
 
 
END_EDIT:
return_code = 0
If modify = "YES" then do
  return_code = 0
  Address ISPEXEC "LMMADD DATAID("temp8") MEMBER("vmember")"
  If return_code = 4 then do
    return_code = 0
    Address ISPEXEC "LMMREP DATAID("temp8") MEMBER("vmember")"
    If return_code <> 0 then,
      Say pgmname "LMMREP_TEMP8_RCODE =" return_code vmember zerrsm
    end
  Else do
    If return_code <> 0 then,
      Say pgmname "LMMADD_TEMP8_RCODE =" return_code vmember zerrsm
      end
  end
 
 
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
cm009rc = return_code
Address ISPEXEC "VPUT (CM09VGET CM009RC) 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 > 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