/* REXX */
/* CLS2REXXed by UMLA01S on 9 Nov 2023 at 09:14:42  */
/*trace ?r*/
Signal On NoValue
Call On Error
Signal On Failure
Signal On Syntax
Parse source opsys . exec_name .
Address ISREDIT
 
"MACRO"               /* CARM0062 EDIT MACRO */
/*********************************************************************/
/* 04/13/2018 CL.FENTON Corrected issue with a single ampersand      */
/*            when setting the UZID field, STS-019759.               */
/* 11/09/2023 CL Fenton Converted script from CLIST to REXX.         */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/
pgmname = "CARM0062 11/09/23"
sysprompt = 'OFF'
syssymlist = 'OFF'
sysconlist = 'OFF'
syslist = 'OFF'
sysmsg = 'ON'
return_code = 0   /* SET RETURN CODE TO 0 */
maxcc = 0
blank = " "
last_loop = "NO"
loop_cnt = 0
dsnameo = ""
 
/*******************************************/
/* VARIABLES ARE PASSED TO THIS MACRO      */
/* CONSLIST                                */
/* COMLIST                                 */
/* SYMLIST                                 */
/* TERMMSGS                                */
/*******************************************/
Address ISPEXEC "VGET (SENSITVE APREFIX ALPHA XTITLE CONSLIST",
  "COMLIST SYMLIST TERMMSGS) ASIS"
cm62vge = 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 "SENSITIVE/"sensitive "APREFIX/"aprefix,
    "ALPHA/"alpha "XTITLE/"xtitle
  return_code = return_code + 16
  SIGNAL ERR_EXIT
  end
 
If CONSLIST = "ON" | COMLIST = "ON" | SYMLIST = "ON",
  then Trace ?r
 
/*******************************************/
/* TURN ON MESSAGES                        */
/*******************************************/
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"
Address ISPEXEC "CONTROL ERRORS RETURN"
"(MEMBER) = MEMBER"
 
/*******************************************/
/* PUT HEADINGS OUT                        */
/*******************************************/
headline = "              "member
ac = headline
Address ISPEXEC "LMPUT DATAID("sensitve") MODE(INVAR) DATALOC(AC)",
  "DATALEN("length(ac)") MEMBER("member")"
headline = " ======================================="
headline = headline"==============================="
headline = headline"==============================="
headline = headline"==============================="
headline = left(' ',133,'=')
ac = headline
Address ISPEXEC "LMPUT DATAID("sensitve") MODE(INVAR) DATALOC(AC)",
  "DATALEN("length(ac)") MEMBER("member")"
ac = " "
Address ISPEXEC "LMPUT DATAID("sensitve") MODE(INVAR) DATALOC(AC)",
  "DATALEN("length(ac)") MEMBER("member")"
 
"(ENDER) = LINENUM .ZLAST"
"CURSOR = 1 1"
"(CURLINE) = LINENUM .ZCSR"
 
/*******************************************/
/* MAIN LOOP                               */
/*******************************************/
 
 
LOOP:
do curline = 1 to ender
  "(DATA) = LINE" curline
 
/*******************************************/
/* CHECK 1 POSITION                        */
/*******************************************/
  data_indicate = substr(data,1,1)
 
  If data_indicate = "L" then do
    ac = " "
    Address ISPEXEC "LMPUT DATAID("sensitve") MODE(INVAR)",
      "DATALOC(AC) DATALEN("length(ac)") MEMBER("member")"
    loop_cnt = 0
    /*SIGNAL  LINED*/
    end
 
  If data_indicate = "D" then,
    call STRIPD
 
  If data_indicate = " " then do
    uzid = strip(substr(data,40),"T")
    ac = "               "uzid
    Address ISPEXEC "LMPUT DATAID("sensitve") MODE(INVAR) DATALOC(AC)",
      "DATALEN("length(ac)") MEMBER("member")"
  /*SIGNAL  STRIPU*/
    end
  /*SIGNAL  LOOP*/
  end
 
return_code = 0
Address ISPEXEC "LMMADD DATAID("sensitve") MEMBER("member")"
If return_code = 4 then do
  return_code = 0
  Address ISPEXEC "LMMREP DATAID("sensitve") MEMBER("member")"
  If return_code <> 0 then do
    Say pgmname "LMMREP_SENSITVE_RC =" return_code member zerrsm
    end
  end
Else do
  If return_code <> 0 then,
    Say pgmname "LMMADD_SENSITVE_RC =" return_code member zerrsm
  end
 
 
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
Address ISPEXEC "VPUT (CM62VGE) ASIS"
/*******************************************/
/* SAVE OUTPUT                             */
/*******************************************/
"END"
Exit
Exit 0
 
/*******************************************/
/* STRIP DATA                              */
/*******************************************/
 
 
STRIPD:
loop_cnt = loop_cnt + 1
dsname1 = substr(data,2,8)
dsname2 = substr(data,11,27)
if dsname2 <> dsnameo then loop_cnt = 1
dsnameo = strip(dsname2,"T")
dsname3 = substr(data,46,8)
uzid = substr(data,62,9)
group = substr(data,81,1)
acc1 = substr(data,71,9)
warn1 = substr(data,84,1)
uacc1 = substr(data,87,8)
audit1 = substr(data,96)
ac = dsname2"        "dsname3"                  "
If loop_cnt = 1 then do
  ac = substr(ac,1,67)
  ac = "     "ac" UACC("uacc1") WARN("warn1")" audit1
  Address ISPEXEC "LMPUT DATAID("sensitve") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER("member")"
  end
 
If group = "G" then,
  uzid1 = "GROUPID("uzid")"
Else,
  If group = "U" then,
    uzid1 = " USERID("uzid")"
  Else,
    uzid1 = "  UNDEF("uzid")"
ac = "          "uzid1" ACCESS("acc1")"
If uzid <> " " then,
  Address ISPEXEC "LMPUT DATAID("sensitve") MODE(INVAR) DATALOC(AC)",
    "DATALEN("length(ac)") MEMBER("member")"
 
/*curline = curline + 1
    SIGNAL LOOP*/
Return
 
 
STRIPU:
uzid = strip(substr(data,40),"T")
ac = "               "uzid
Address ISPEXEC "LMPUT DATAID("sensitve") MODE(INVAR) DATALOC(AC)",
  "DATALEN("length(ac)") MEMBER("member")"
/*curline = curline + 1
  SIGNAL  LOOP*/
Return
 
 
LINED:
line1 = substr(data,2)
ac = " "
Address ISPEXEC "LMPUT DATAID("sensitve") MODE(INVAR) DATALOC(AC)",
  "DATALEN("length(ac)") MEMBER("member")"
loop_cnt = 0
/*curline = curline + 1
  SIGNAL  LOOP*/
Return
 
 
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
