/* REXX */
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
Address TSO
 
/*********************************************************************/
/* AUTHOR: Charles Fenton                                            */
/*                                                                   */
/*********************************************************************/
/* DISPLAY SYSTEM INFORMATION ON TERMINAL                            */
/*********************************************************************/
/* This merges specific PDI members into one member.                 */
/*********************************************************************/
/* Change summary:                                                   */
/*   2018/08/08 - CLF, Initial creation.                             */
/*   2018/08/08 - CLF, Merge Zxxx002A to the begining of Zxxx0020    */
/*                of the INCONTROL products if Zxxx002A is a         */
/*                finding, STS-019703.                               */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname  = "CACC041W 08/08/18"
CONSLIST = 'OFF'                   /* DEFAULT IS OFF                       */
COMLIST  = 'OFF'                   /* DEFAULT IS OFF                       */
SYMLIST  = 'OFF'                   /* DEFAULT IS OFF                       */
TERMMSGS = 'OFF'                   /* DEFAULT IS OFF                       */
PDIDDN   = 'PDIDD'                 /* PDI DDNAME                           */
TRACE    = 'OFF'                   /* TRACE ACTIONS AND ERRORS */
Numeric digits 10                           /* dflt of 9 not enough  */
 
Arg OPTION
If option <> "" then 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         */
x = outtrap('msgs.')
zispfrc = 0
Address ISPEXEC "VPUT (ZISPFRC) SHARED"
return_code = 0
mbrlist = "ZCTD002 ZCTM002 ZCTO002 ZIOA002"
 
 
/* *************************************** */
/* INITIALIZE LIBRARY MANAGEMENT           */
/* *************************************** */
x = listdsi(pdiddn "file")
pdidsn = sysdsname
return_code = 0
do aa = 1 to words(mbrlist)
  datarec. = ""
  mbra = word(mbrlist,aa)"A"
  mbr0 = word(mbrlist,aa)"0"
  datarec. = ""
  call read_dsnmbr pdiddn mbra
  if result = 4 then iterate
  mcnt = 1
  nf = ""
  do x = 1 to rec.0
    if pos("Not a Finding",rec.x) = 1 then do
      mcnt = 0
      nf = "Y"
      leave
      end
    datarec.mcnt = rec.x
    mcnt = mcnt + 1
    end
  if nf <> "Y" then do
    nf = ""
    datarec.mcnt = " "
    mcnt = mcnt + 1
    ocnt = mcnt
    datarec. = ""
    call read_dsnmbr pdiddn mbr0
    do x = 1 to rec.0
      if pos("Not a Finding",rec.x) = 1 then do
        nf = "Y"
        mcnt = 0
        leave
        end
      datarec.mcnt = rec.x
      mcnt = mcnt + 1
      end
    if nf <> "Y" then do
      datarec.mcnt = ""
      datarec.0 = mcnt + 1
      end
    else do
      datarec.mcnt = ""
      datarec.0 = ocnt + 1
      end
    "alloc fi(dd1) da('"pdidsn"("mbr0")') shr reuse"
    "execio * diskw dd1 (finis stem datarec."
    "free fi(dd1)"
    end
  "DELETE ('"pdidsn"("mbra")')"
  end
rec. = ""
return_code = 0
/* *************************************** */
/* ERROR EXIT                              */
/* *************************************** */
ERR_EXIT:
If return_code > 0 then do
  Address ISPEXEC "VGET (ZISPFRC) SHARED"
  zispfrc = return_code
  Address ISPEXEC "VPUT (ZISPFRC) SHARED"
  Say pgmname "ZISPFRC =" zispfrc
  end
Exit (0)
 
 
read_dsnmbr:
parse arg ddn m
if ddn = "" & m = "" then return 4
x = listdsi(ddn "file")
if x > 0 then do
  say pgmname 'SYSREASON:' SYSREASON
  say pgmname SYSMSGLVL2
  return 4
  end
if sysdsn("'"SYSDSNAME"("m")'") <> "OK" then return 4
If termmsgs = "ON" then,
  say pgmname "Processing dataset:" sysdsname "member:" m"."
dd1 = SYSDSNAME
"alloc fi(dd1) da('"SYSDSNAME"("m")') shr reuse"
"execio * diskr dd1 (finis stem rec."
"free fi(dd1)"
return 0
 
 
NoValue:
Failure:
Syntax:
say pgmname 'REXX error' rc 'in line' sigl':' strip(ERRORTEXT(rc))
say SOURCELINE(sigl)
Exit
 
 
Error:
return_code = rc
If return_code >= 16 then do
  say pgmname "LASTCC =" RC
  say pgmname 'REXX error' rc 'in line' sigl':' ERRORTEXT(rc)
  end
return
 
 
