/* REXX */
/* CLS2REXXed by FSOX001 on 17 Jan 2018 at 13:08:13  */
/*trace ?r*/
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
 
/*********************************************************************/
/* 08/05/2004 JL Nelson ADDED code to check security system          */
/* 08/05/2004 JL Nelson ADDED EXIT code                              */
/* 08/06/2004 JL Nelson ADDED code to locate Started Task PROCs      */
/* 12/15/2004 JL Nelson Unable to find TCPIP in some MSTJCL LPARs.   */
/* 02/11/2005 JL Nelson Changed constants to variables before rename */
/* 06/09/2005 JL Nelson Pass MAXCC in ZISPFRC variable               */
/* 06/15/2005 JL Nelson Reset return code to end job step            */
/* 07/07/2005 JL Nelson Correct spelling error                       */
/* 07/14/2005 JL Nelson Added code for PROFILE/SYSTCPD/SYSFTPD not   */
/*            found.                                                 */
/* 11/14/2005 CL Fenton Replaced with Charles modifications          */
/* 11/30/2005 CL Fenton Removed some WRITEs and modified stats at    */
/*            end.                                                   */
/* 03/20/2006 JL Nelson Fixed LMINIT STDSN RC = 8 Invalid DSN -      */
/*            quotes.                                                */
/* 03/21/2006 JL Nelson Made changes to avoid SUBSTR abend 920/932.  */
/* 03/21/2006 JL Nelson Set/test RCode for every ISPEXEC command.    */
/* 03/21/2006 JL Nelson Use NRSTR avoid abend 900 if ampersand in    */
/*            data.                                                  */
/* 04/06/2006 JL Nelson Pass PARMLIB dataset name for INCLUDE stmts. */
/* 04/17/2006 JL Nelson Check return codes from LISTDSI.             */
/* 10/09/2008 CL Fenton Added analysis for TN3270 and corrected      */
/*            errors in the ITNTxxxx PDIs.                           */
/* 07/16/2009 CL Fenton Added collection of tables and dsnlist       */
/*            members.                                               */
/* 10/09/2009 CL Fenton Chgd to CACC3000 to only issue JES2 commands */
/*            once.                                                  */
/* 11/26/2012 CL Fenton Added ISPEXEC CONTROL statements and removed */
/*            TOMEM from LMCOPY statements for PDS data sets,        */
/*            STS-001269.                                            */
/* 05/29/2014 CL Fenton Chgs made to add DIALOG information for      */
/*            CSFTP CSTCP, and CSTNT, STS-000653.                    */
/* 08/01/2017 CL Fenton Chgs made to add check for RACF SERVAUTH     */
/*            resource class being active for CSTCP, STS-017968.     */
/* 01/22/2018 CL Fenton Converted script from CLIST to REXX.         */
/* 06/14/2018 CL Fenton Deleted CACM0420 varible.                    */
/* 03/06/2019 CL Fenton Corrected possible error on variables not    */
/*            being initialized.                                     */
/* 09/16/2020 CL Fenton Corrected errors caused from variables not   */
/*            being initialized, STS-025280.                         */
/* 10/18/2024 CL Fenton Added ENQ(EXCLU) to the LMINIT for PDIDD     */
/*            allocation.                                            */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CACC0004 10/18/24"
CONSLIST = "OFF"                  /* DEFAULT IS OFF                  */
COMLIST  = "OFF"                  /* DEFAULT IS OFF                  */
SYMLIST  = "OFF"                  /* DEFAULT IS OFF                  */
TERMMSGS = "OFF"                  /* DEFAULT IS OFF                  */
TCPDSN   = ""
TCPMBR   = "TCPIP"                /* Default member                  */
TNDSN    = ""
TNMBR    = "TN3270"               /* Default member                  */
FTPDSN   = ""
FTPMBR   = "FTPD"                 /* Default member                  */
TYPERUN  = "FSO"                  /* Run for SRRAUDIT | FSO          */
PRODUCTS = "PRODUCTS"             /* Dialog product member name      */
CACC1000 = "CACC1000"             /* Retrieve PROCLIB datasets       */
CACC3000 = "CACC3000"             /* Retrieve PROCLIB datasets       */
CACM000C = "CACM000C"             /* Script to review products       */
CACM0411 = "CACM0011"             /* Edit macro for TCP proc         */
CACM0412 = "CACM0012"             /* Edit macro for tcpdata          */
CACM0413 = "CACM0013"             /* Edit macro for tcp profile      */
CACM0414 = "CACM0014"             /* Edit macro for FTP proc         */
CACM0415 = "CACM0015"             /* Edit macro for ftpdata          */
CACT0000 = "CACT0000"             /* Dialog access table             */
CACT0004 = "CACT0004"             /* PDI list                        */
CACT0008 = "CACT0008"             /* PDI list                        */
CACTPROD = "CACTPROD"             /* PDI list                        */
CACM000D = "CACM000D"             /* DSNLIST generator               */
DSNLIST  = "DSNLIST"              /* DSNLIST generator               */
CACM000T = "CACM000T"             /* Edit macro for CT0401/stc*      */
DATADDN  = "DIALOG"               /* Dialog DD name for review       */
TBLDDN   = "TABLE"                /* TABLE DDNAME                    */
CNTLDDN  = "CNTL"                 /* CNTL DDNAME                     */
PDIDD    = "PDIDD"                /* PDI DDNAME                      */
TRACE    = "OFF"                  /* TRACE ACTIONS AND ERRORS        */
sysflush = "OFF"                  /* CONTROL NOFLUSH                 */
Numeric digits 10                 /* default of 9 not enough         */
maxcc = 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
 
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"
 
/***********************************************/
/* CONSLIST = CONLIST                          */
/* COMLIST  = LIST                             */
/* TERMMSGS = MESSAGES                         */
/* TRACE TURNS ON MESSAGING                    */
/* TCPDSN TCPIP PROCEDURE DATASET              */
/* TCPMBR TCPIP PROCEDURE                      */
/* FTPDSN FTP PROCEDURE DATASET                */
/* FTPMBR FTP PROCEDURE                        */
/***********************************************/
return_code = 0
cm11vget          = "N/A"
cm12vget          = "N/A"
cm13vget          = "N/A"
cm14vget          = "N/A"
cm15vget          = "N/A"
edit_ftpmbr_rc    = "N/A"
edit_pfdsn_rc     = "N/A"
edit_ptdsn_rc     = "N/A"
edit_stdsn_rc     = "N/A"
edit_tcpmbr_rc    = "N/A"
edit_tnmbr_rc     = "N/A"
lmclose_cntl_rc   = "N/A"
lmclose_pdidd_rc  = "N/A"
lmcomp_pdidd_rc   = "N/A"
lmcopy_pfdsn_rc   = "N/A"
lmcopy_ptdsn_rc   = "N/A"
lmcopy_stdsn_rc   = "N/A"
lmcopy_syslib_rc  = "N/A"
lmcopy_syslib1_rc = "N/A"
lmcopy_syslib2_rc = "N/A"
lmfree_cntl_rc    = "N/A"
lmfree_dialog_rc  = "N/A"
lmfree_pdidd_rc   = "N/A"
lmfree_pfdsn_rc   = "N/A"
lmfree_ptdsn_rc   = "N/A"
lmfree_stdsn_rc   = "N/A"
lmfree_syslib_rc  = "N/A"
lmfree_syslib1_rc = "N/A"
lmfree_syslib2_rc = "N/A"
lmfree_table_rc   = "N/A"
lmfree_temp9_rc   = "N/A"
lminit_cntl_rc    = "N/A"
lminit_dialog_rc  = "N/A"
lminit_pdidd_rc   = "N/A"
lminit_pfdsn_rc   = "N/A"
lminit_ptdsn_rc   = "N/A"
lminit_stdsn_rc   = "N/A"
lminit_syslib_rc  = "N/A"
lminit_syslib1_rc = "N/A"
lminit_syslib2_rc = "N/A"
lminit_table_rc   = "N/A"
lminit_temp9_rc   = "N/A"
vput_rc           = "N/A"
zispfrc = 0
"VPUT (ZISPFRC) SHARED"
return_code = 0
"VPUT (CONSLIST COMLIST SYMLIST TERMMSGS TYPERUN DSNLIST",
  "CACM000D CACT0000 CACT0004 CACT0008 CACTPROD) ASIS"
cc04vput = return_code
 
If return_code <> 0 then do
  Say pgmname "VPUT RC =" return_code   zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
/* Determine which security system is running */
return_code = 0
"SELECT CMD("cacc1000 "ACP)"
"VGET (ACPNAME ACPVERS) ASIS"
 
/*******************************************/
/* DETERMINE ACP AND SET VARIABLE          */
/*******************************************/
 
If acpname = " " then do
  Say pgmname "Unable to determine security system."
  Say pgmname "Name" acpname "Version" acpvers
  return_code = 20
  SIGNAL ERR_EXIT
  end
 
acp = left(acpname" ",1)
 
/*******************************************/
/* INITIALIZE LIBRARY MANAGEMENT           */
/*******************************************/
"LMINIT DATAID(DATAID) DDNAME("dataddn")"
lminit_dialog_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT_DIALOG_RC =" return_code zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
"LMINIT DATAID(CNTLID) DDNAME("cntlddn")"
lminit_cntl_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT_CNTL_RC =" return_code zerrsm
  Say pgmname zerrlm
  SIGNAL  ERR_EXIT
  end
 
"LMINIT DATAID(TBLID) DDNAME("tblddn")"
lminit_table_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT_TABLE_RC" return_code  zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
"LMOPEN DATAID("cntlid")"
lmopen_cntl_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN_CNTL_RC" return_code  zerrsm
  Say pgmname zerrlm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
lp = "("
rp = ")"
typerun_data = "CSTCP CSFTP CSTNT"
 
Do x = 1 to words(typerun_data)
  typerun = word(typerun_data,x)
  "VPUT (TYPERUN CNTLID PDIDD TBLID) ASIS"
  "EDIT DATAID("dataid") MACRO("cacm000c") MEMBER("products")"
  "VGET (MBR DSN) ASIS"
  If typerun = "CSFTP" then do
    ftpmbr = strip(mbr,"t")
    ftpdsn = strip(dsn,"t")
    end
  If typerun = "CSTCP" then do
    tcpmbr = strip(mbr,"t")
    tcpdsn = strip(dsn,"t")
    end
  If typerun = "CSTNT" then do
    tnmbr = strip(mbr,"t")
    tndsn = strip(dsn,"t")
    end
  end
 
If tcpmbr = " " then do
  Say pgmname "MUST SPECIFY THE TCPMBR PARAMETER."
  return_code = 21
  SIGNAL  ERR_EXIT
  end
 
If ftpmbr = " " then do
  Say pgmname "MUST SPECIFY THE FTPMBR PARAMETER."
  return_code = 22
  SIGNAL  ERR_EXIT
  end
 
/*******************************************/
/* Locate started task PROCs               */
/*******************************************/
 
proc_msg = "JES2 PROC00"
If tcpdsn = " " then do
  "SELECT CMD("cacc3000 "FIND JESPROC" tcpmbr")"
  "VGET (FOUND) ASIS"
  If found = " " then do
    Say pgmname "TCPIP procedure" tcpmbr "was not found in the",
      proc_msg "concatenation."
    return_code = 23
    SIGNAL  ERR_EXIT
    end
  tcpdsn = found
  end
 
If ftpdsn = " " then do
  "SELECT CMD("cacc3000 "FIND JESPROC" ftpmbr")"
  "VGET (FOUND) ASIS"
  If found = " " then do
    Say pgmname "FTPD procedure" ftpmbr "was not found in the",
      proc_msg "concatenation."
    return_code = 24
    SIGNAL  ERR_EXIT
    end
  ftpdsn = found
  end
 
return_code = 0
"LMINIT DATAID(PDIDD) DDNAME(PDIDD) ENQ(EXCLU)"
lminit_pdidd_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT PDIDD RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
return_code = 0
"LMINIT DATAID(TEMP9) DDNAME(TEMP9)"
lminit_temp9_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT TEMP9 RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
return_code = 0
ptdsn = " "
stdsn = " "
pfdsn = " "
sfdsn = " "
 
"VPUT (PTDSN STDSN PFDSN SFDSN) ASIS"
 
If tcpmbr <> "NONE" & tcpdsn <> "NONE" then do
  If acpname = "RACF" then do
    typerun = "TEXT"
    dsns = "ITCPR052SERVAUTH"
    tblmbr = " "
    "VPUT (TYPERUN TBLMBR DSNS) ASIS"
    "EDIT DATAID("tblid") MEMBER(CART0000) MACRO(CACM000D)"
    end
 
  locate = sysdsn("'"tcpdsn"("tcpmbr")'")
  If locate <> "OK" then do
    Say pgmname "DSN="tcpdsn "MEMBER="tcpmbr locate
    return_code = 26
    SIGNAL  ERR_EXIT
    end
  Say pgmname "Using procedure" tcpmbr "from" tcpdsn
  end
 
If ftpmbr <> "NONE" & ftpdsn <> "NONE" then do
  locate = sysdsn("'"ftpdsn"("ftpmbr")'")
  If locate <> "OK" then do
    Say pgmname "DSN="ftpdsn "MEMBER="ftpmbr locate
    return_code = 27
    SIGNAL  ERR_EXIT
    end
  Say pgmname "Using procedure" ftpmbr "from" ftpdsn
  end
 
If tnmbr <> "NONE" & tndsn <> "NONE" then do
  locate = sysdsn("'"tndsn"("tnmbr")'")
  If locate <> "OK" then do
    Say pgmname "DSN="tndsn "MEMBER="tnmbr locate
    return_code = 28
    SIGNAL  ERR_EXIT
    end
  Say pgmname "Using procedure" tnmbr "from" tndsn
  end
 
If tcpmbr <> "NONE" & tcpdsn <> "NONE" then do
  return_code = 0
  "LMINIT DATAID(TCPDSNID) DATASET('"tcpdsn"')"
  lminit_syslib_rc = return_code
  If return_code <> 0 then do
    Say pgmname "LMINIT TCPDSN/"tcpdsn "RC =" return_code zerrsm
    return_code = return_code + 16
    SIGNAL  ERR_EXIT
    end
  end
 
If ftpmbr <> "NONE" & ftpdsn <> "NONE" then do
  return_code = 0
  "LMINIT DATAID(FTPDSNID) DATASET('"ftpdsn"')"
  lminit_syslib1_rc = return_code
  If return_code <> 0 then do
    Say pgmname "LMINIT FTPDSN/"ftpdsn "RC =" return_code zerrsm
    return_code = return_code + 16
    SIGNAL  ERR_EXIT
    end
  end
 
If tnmbr <> "NONE" & tndsn <> "NONE" then do
  return_code = 0
  "LMINIT DATAID(TNDSNID) DATASET('"tndsn"')"
  lminit_syslib2_rc = return_code
  If return_code <> 0 then do
    Say pgmname "LMINIT TNDSN/"tndsn "RC =" return_code zerrsm
    return_code = return_code + 16
    SIGNAL  ERR_EXIT
    end
  end
 
typerun = "FSO"
"VPUT (TYPERUN) ASIS"
return_code = 0
"VIEW DATAID("tblid") MACRO("cacm000t") MEMBER("cact0000")"
/*******************************************/
return_code = 0
"LMOPEN DATAID("pdidd") OPTION(OUTPUT)"
lmopen_pdidd_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMOPEN PDIDD RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
/*******************************************/
/* COPY PROCLIB MEMBER                     */
/*******************************************/
 
 
IEASYS_COPY:
If tcpmbr <> "NONE" & tcpdsn <> "NONE" then do
  return_code = 0
  "LMCOPY FROMID("tcpdsnid") FROMMEM("tcpmbr") TODATAID("temp9")",
    "REPLACE"
  lmcopy_syslib_rc = return_code
  If return_code <> 0 then do
    Say pgmname "LMCOPY Member" tcpmbr "RC =" return_code zerrsm
    Say pgmname "From" tcpdsn "To TEMP9"
    return_code = return_code + 16
    SIGNAL  ERR_EXIT
    end
  end
 
If ftpmbr <> "NONE" & ftpdsn <> "NONE" then do
  return_code = 0
  "LMCOPY FROMID("ftpdsnid") FROMMEM("ftpmbr") TODATAID("temp9")",
    "REPLACE"
  lmcopy_syslib1_rc = return_code
  If return_code <> 0 then do
    Say pgmname "LMCOPY Member" ftpmbr "RC =" return_code zerrsm
    Say pgmname "From" ftpdsn "To TEMP9"
    return_code = return_code + 16
    SIGNAL  ERR_EXIT
    end
  end
 
If tnmbr <> "NONE" & tndsn <> "NONE" then do
  return_code = 0
  "LMCOPY FROMID("tndsnid") FROMMEM("tnmbr") TODATAID("temp9")",
    "REPLACE"
  lmcopy_syslib2_rc = return_code
  If return_code <> 0 then do
    Say pgmname "LMCOPY Member" tnmbr "RC =" return_code zerrsm
    Say pgmname "From" tndsn "To TEMP9"
    return_code = return_code + 16
    SIGNAL  ERR_EXIT
    end
  end
 
return_code = 0
"LMFREE DATAID("dataid")"
lmfree_dialog_rc = return_code
 
return_code = 0
If tcpmbr <> "NONE" & tcpdsn <> "NONE" then do
  "LMFREE DATAID("tcpdsnid")"
  lmfree_syslib_rc = return_code
  end
 
return_code = 0
If ftpmbr <> "NONE" & ftpdsn <> "NONE" then do
  "LMFREE DATAID("ftpdsnid")"
  lmfree_syslib1_rc = return_code
  end
 
return_code = 0
If tnmbr <> "NONE" & tndsn <> "NONE" then do
  "LMFREE DATAID("tndsnid")"
  lmfree_syslib2_rc = return_code
  end
 
return_code = 0
"VPUT (PDIDD TBLID TCPMBR TNMBR ACP) ASIS"
vput_rc = return_code
If return_code <> 0 then do
  Say pgmname "VPUT PDIDD ACP RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
return_code = 0
tnprof = " "
If tnmbr <> "NONE" & tndsn <> "NONE" then do
  "EDIT DATAID("temp9") MACRO("cacm0411") MEMBER("tnmbr")"
  edit_tnmbr_rc = return_code
  If return_code > 4 then do
    Say pgmname "EDIT TEMP9" tnmbr "RC =" return_code zerrsm
    return_code = return_code + 16
    SIGNAL  ERR_EXIT
    end
  "VGET (PTDSN) ASIS"
  tnprof = ptdsn
  end
 
"VPUT (TNPROF) ASIS"
 
return_code = 0
If tcpmbr <> "NONE" & tcpdsn <> "NONE" then,
  "EDIT DATAID("temp9") MACRO("cacm0411") MEMBER("tcpmbr")"
edit_tcpmbr_rc = return_code
If return_code > 4 then do
  Say pgmname "EDIT TEMP9" tcpmbr "RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
return_code = 0
If ftpmbr <> "NONE" & ftpdsn <> "NONE" then,
  "EDIT DATAID("temp9") MACRO("cacm0414") MEMBER("ftpmbr")"
edit_ftpmbr_rc = return_code
If return_code > 4 then do
  Say pgmname "EDIT TEMP9" ftpmbr "RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
"VGET (PTDSN STDSN PFDSN SFDSN) ASIS"
 
return_code = 0
If tcpmbr <> "NONE" & tcpdsn <> "NONE" then,
  If stdsn = " " then do
    Say pgmname "The SYSTCPD DD statement was not found in the",
      "TCP startup procedure."
    end
  Else,
    SIGNAL  SYSTCPD_FOUND
 
If ftpmbr <> "NONE" & ftpdsn <> "NONE" then,
  If sfdsn = " " then do
    Say pgmname "The SYSTCPD DD statement was not found in the",
      "FTP startup procedure."
    return_code = return_code + 16
    SIGNAL  ERR_EXIT
    end
  Else,
    stdsn = sfdsn
 
 
SYSTCPD_FOUND:
return_code = 0
If tcpmbr= "NONE" & tcpdsn = "NONE" then,
  SIGNAL  BYPASS_STDSN
parmdsn = stdsn
member = "STDSN"
x = listdsi("'"stdsn"'")
 
If sysreason = 0 then,
  stdsorg = sysdsorg
Else do
  Say pgmname "The SYSTCPD DD statement is invalid." stdsn
  Say pgmname sysmsglvl1 "SYSREASON=" sysreason
  Say pgmname sysmsglvl2
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
If stdsorg = "PO" then do
  parse var stdsn parmdsn "(" member ")" .
  end
Say pgmname
Say pgmname "The following data set names can be entered into the"
Say pgmname "DSNLIST for the report specified before the dataset."
Say pgmname "   TCPRPT" parmdsn
dsns = "TCPRPT" parmdsn
"VPUT (DSNS) ASIS"
"EDIT DATAID("tblid") MEMBER("dsnlist") MACRO("cacm000d")"
 
return_code = 0
"LMINIT DATAID(STDSNID) DATASET('"parmdsn"')"
lminit_stdsn_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT STDSN/"parmdsn "RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
return_code = 0
If stdsorg = "PO" then,
  "LMCOPY FROMID("stdsnid") FROMMEM("member") TODATAID("temp9")",
    "REPLACE"
Else,
  "LMCOPY FROMID("stdsnid") TODATAID("temp9") TOMEM("member")",
    "REPLACE"
lmcopy_stdsn_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMCOPY Member" member "RC =" return_code zerrsm
  Say pgmname "From" parmdsn "To TEMP9"
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
return_code = 0
"LMFREE DATAID("stdsnid")"
lmfree_stdsn_rc = return_code
 
return_code = 0
"VPUT (PARMDSN) ASIS"
If return_code <> 0 then,
  Say pgmname "VPUT STDSN/"parmdsn "RC =" return_code zerrsm
 
return_code = 0
"EDIT DATAID("temp9") MACRO("cacm0412") MEMBER("member")"
edit_stdsn_rc = return_code
If return_code > 4 then do
  Say pgmname "EDIT TEMP9" member "RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
 
BYPASS_STDSN:
return_code = 0
If ptdsn = " " then do
  Say pgmname "The PROFILE DD statement was not found in the TCP",
    "startup procedure."
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
parmdsn = ptdsn
member = "PTDSN"
x = listdsi("'"ptdsn"'")
 
If sysreason = 0 then,
  ptdsorg = sysdsorg
Else do
  Say pgmname "The PROFILE DD statement is invalid." ptdsn
  Say pgmname sysmsglvl1 "SYSREASON=" sysreason
  Say pgmname sysmsglvl2
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
If ptdsorg = "PO" then do
  parse var ptdsn parmdsn "(" member ")" .
  end
 
Say pgmname "   TCPRPT" parmdsn
dsns = "TCPRPT" parmdsn
"VPUT (DSNS) ASIS"
"EDIT DATAID("tblid") MEMBER("dsnlist") MACRO("cacm000d")"
 
return_code = 0
"LMINIT DATAID(PTDSNID) DATASET('"parmdsn"')"
lminit_ptdsn_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT PTDSN/"parmdsn  "RC =" return_code  zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
return_code = 0
If ptdsorg = "PO" then,
  "LMCOPY FROMID("ptdsnid") FROMMEM("member") TODATAID("temp9")",
    "REPLACE"
Else,
  "LMCOPY FROMID("ptdsnid") TODATAID("temp9") TOMEM("member")",
    "REPLACE"
lmcopy_ptdsn_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMCOPY Member" member "RC =" return_code zerrsm
  Say pgmname "From" parmdsn "To TEMP9"
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
return_code = 0
"LMFREE DATAID("ptdsnid")"
lmfree_ptdsn_rc = return_code
 
return_code = 0
"VPUT (PARMDSN) ASIS"
If return_code <> 0 then,
  Say pgmname "VPUT PTDSN/"parmdsn "RC =" return_code zerrsm
 
return_code = 0
"EDIT DATAID("temp9") MACRO("cacm0413") MEMBER("member")"
edit_ptdsn_rc = return_code
If return_code > 4 then do
  Say pgmname "EDIT TEMP9" member "RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
If ftpmbr= "NONE" & ftpdsn = "NONE" then,
  SIGNAL  BYPASS_PTDSN
If pfdsn = " " then do
  Say pgmname "The SYSFTPD DD statement was not found in the FTP",
    "startup procedure."
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
parmdsn = pfdsn
member = "PFDSN"
x = listdsi("'"pfdsn"'")
 
If sysreason = 0 then,
  pfdsorg = sysdsorg
Else do
  Say pgmname "The SYSFTPD DD statement is invalid." pfdsn
  Say pgmname sysmsglvl1 "SYSREASON=" sysreason
  Say pgmname sysmsglvl2
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
If pfdsorg = "PO" then do
  parse var pfdsn parmdsn "(" member ")" .
  end
 
Say pgmname "   FTPRPT" parmdsn
dsns = "FTPRPT" parmdsn
"VPUT (DSNS) ASIS"
"EDIT DATAID("tblid") MEMBER("dsnlist") MACRO("cacm000d")"
 
return_code = 0
"LMINIT DATAID(PFDSNID) DATASET('"parmdsn"')"
lminit_pfdsn_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMINIT PFDSN/"parmdsn "RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
return_code = 0
If pfdsorg = "PO" then,
  "LMCOPY FROMID("pfdsnid") FROMMEM("member") TODATAID("temp9")",
    "REPLACE"
Else,
  "LMCOPY FROMID("pfdsnid") TODATAID("temp9") TOMEM("member")",
    "REPLACE"
lmcopy_pfdsn_rc = return_code
If return_code <> 0 then do
  Say pgmname "LMCOPY Member" member "RC =" return_code zerrsm
  Say pgmname "From" parmdsn "To TEMP9"
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
return_code = 0
"LMFREE DATAID("pfdsnid")"
lmfree_pfdsn_rc = return_code
 
return_code = 0
"VPUT (PARMDSN) ASIS"
If return_code <> 0 then,
  Say pgmname "VPUT PFDSN/"parmdsn "RC =" return_code zerrsm
 
return_code = 0
"EDIT DATAID("temp9") MACRO("cacm0415") MEMBER("member")"
edit_pfdsn_rc = return_code
If return_code > 4 then do
  Say pgmname "EDIT TEMP9" member "RC =" return_code zerrsm
  return_code = return_code + 16
  SIGNAL  ERR_EXIT
  end
 
/*******************************************/
/* CLOSE OUTPUT                            */
/*******************************************/
 
 
BYPASS_PTDSN:
return_code = 0
"LMCLOSE DATAID("cntlid")"
lmclose_cntl_rc = return_code
If return_code <> 0 then,
  Say pgmname "LMCLOSE CNTL RC =" return_code zerrsm
 
return_code = 0
"LMCLOSE DATAID("pdidd")"
lmclose_pdidd_rc = return_code
If return_code <> 0 then,
  Say pgmname "LMCLOSE PDIDD RC =" return_code zerrsm
 
return_code = 0
"LMCOMP DATAID("pdidd")"
lmcomp_pdidd_rc = return_code
 
/*******************************************/
/* FREE FILES                              */
/*******************************************/
return_code = 0
"LMFREE DATAID("cntlid")"
lmfree_cntl_rc = return_code
 
return_code = 0
"LMFREE DATAID("tblid")"
lmfree_table_rc = return_code
 
return_code = 0
"LMFREE DATAID("pdidd")"
lmfree_pdidd_rc = return_code
 
return_code = 0
"LMFREE DATAID("temp9")"
lmfree_temp9_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 (CM11VGET CM12VGET CM13VGET CM14VGET CM15VGET) ASIS"
If termmsgs = "ON" then do
  Say
  Say "==============================================================="
  Say pgmname "LMINIT_CNTL_RC           " lminit_cntl_rc
  Say pgmname "LMINIT_DIALOG_RC         " lminit_dialog_rc
  Say pgmname "LMINIT_SYSLIB_RC         " lminit_syslib_rc
  Say pgmname "LMINIT_SYSLIB1_RC        " lminit_syslib1_rc
  Say pgmname "LMINIT_SYSLIB2_RC        " lminit_syslib2_rc
  Say pgmname "LMINIT_PDIDD_RC          " lminit_pdidd_rc
  Say pgmname "LMINIT_TABLE_RC          " lminit_table_rc
  Say pgmname "LMINIT_TEMP9_RC          " lminit_temp9_rc
  Say pgmname "LMCOPY_SYSLIB_RC         " lmcopy_syslib_rc
  Say pgmname "LMCOPY_SYSLIB1_RC        " lmcopy_syslib1_rc
  Say pgmname "LMCOPY_SYSLIB2_RC        " lmcopy_syslib2_rc
  Say pgmname "LMFREE_SYSLIB_RC         " lmfree_syslib_rc
  Say pgmname "LMFREE_SYSLIB1_RC        " lmfree_syslib1_rc
  Say pgmname "LMFREE_SYSLIB2_RC        " lmfree_syslib2_rc
  Say pgmname "VPUT_RC                  " vput_rc
  Say pgmname "EDIT_TNMBR_RC            " edit_tnmbr_rc
  Say pgmname "EDIT_TCPMBR_RC           " edit_tcpmbr_rc
  If edit_tcpmbr_rc <> 0 then,
    Say pgmname cacm0411 "VGET            " cm11vget
  Say pgmname "EDIT_FTPMBR_RC           " edit_ftpmbr_rc
  If edit_ftpmbr_rc <> 0 then,
    Say pgmname cacm0414 "VGET            " cm14vget
  Say pgmname "LMINIT_STDSN_RC          " lminit_stdsn_rc
  Say pgmname "LMCOPY_STDSN_RC          " lmcopy_stdsn_rc
  Say pgmname "LMFREE_STDSN_RC          " lmfree_stdsn_rc
  Say pgmname "EDIT_STDSN_RC            " edit_stdsn_rc
  If edit_stdsn_rc <> 0 then,
    Say pgmname cacm0412 "VGET            " cm12vget
  Say pgmname "LMINIT_PTDSN_RC          " lminit_ptdsn_rc
  Say pgmname "LMCOPY_PTDSN_RC          " lmcopy_ptdsn_rc
  Say pgmname "LMFREE_PTDSN_RC          " lmfree_ptdsn_rc
  Say pgmname "EDIT_PTDSN_RC            " edit_ptdsn_rc
  If edit_ptdsn_rc <> 0 then,
    Say pgmname cacm0413 "VGET            " cm13vget
  Say pgmname "LMINIT_PFDSN_RC          " lminit_pfdsn_rc
  Say pgmname "LMCOPY_PFDSN_RC          " lmcopy_pfdsn_rc
  Say pgmname "LMFREE_PFDSN_RC          " lmfree_pfdsn_rc
  Say pgmname "EDIT_PFDSN_RC            " edit_pfdsn_rc
  If edit_pfdsn_rc <> 0 then,
    Say pgmname cacm0415 "VGET            " cm15vget
  Say pgmname "LMCLOSE_CNTL_RC          " lmclose_cntl_rc
  Say pgmname "LMCLOSE_PDIDD_RC         " lmclose_pdidd_rc
  Say pgmname "LMCOMP_PDIDD_RC          " lmcomp_pdidd_rc
  Say pgmname "LMFREE_CNTL_RC           " lmfree_cntl_rc
  Say pgmname "LMFREE_DIALOG_RC         " lmfree_dialog_rc
  Say pgmname "LMFREE_PDIDD_RC          " lmfree_pdidd_rc
  Say pgmname "LMFREE_TABLE_RC          " lmfree_table_rc
  Say pgmname "LMFREE_TEMP9_RC          " lmfree_temp9_rc
  Say "==============================================================="
  end /* do - 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 > 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
 
 
