/* REXX SAVELOGS Call this each morning before entering ISPF to print and delete yesterday's SPFLOGx. Written by Frank Clarke, Oldsmar, FL Impact Analysis . SYSPROC TRAPOUT . SYSPROC PACKLOGS Modification History 20010612 fxc how did that happen? The ALLOC for SYSUT1 got dropped and SAVELOGS has been failing quietly since 6/8. */ address TSO /* REXXSKEL ver.19980225 */ arg parms "((" opts signal on syntax signal on novalue call TOOLKIT_INIT /* conventional start-up -*/ rc = trace(tv) info = parms /* to enable parsing */ if Sysvar("SYSISPF") = "ACTIVE" then do, forever address ISPEXEC "SELECT PGM(ISPLLP) PARM(LOG) SUSPEND" if rc = 0 then leave end /* forever */ call A_INIT /* -*/ call B_WALK_CATALOG /* -*/ if sw.0pak then "PACKLOGS FORCE" /* do the Pack now. */ exit /*@ SAVELOGS */ /* . ----------------------------------------------------------------- */ A_INIT: /*@ */ if branch then call BRANCH address TSO via_vps = SWITCH("VPS") /* VPS in parms ? */ sw.0pak = SWITCH("PACK") /* Pack order ? */ prdest = KEYWD("ON") /* printer specified ? */ sw.0NOPRINT = prdest = "" /* don't print if blank */ front = Userid()".SAVELOG" rc = Outtrap("lc.") "LISTC LVL("Userid()".*.LIST)" /* get all .LIST datasets */ rc = Outtrap("off") today = Right(date("S"),6,0) conf. = "" conf.0 = 0 return /*@ A_INIT */ /* . ----------------------------------------------------------------- */ B_WALK_CATALOG: /*@ */ if branch then call BRANCH address TSO do ii = 1 to lc.0 /* for each line... */ if Word(lc.ii,1) = "NONVSAM" then do/* it's a dataset line */ dsn = Word(lc.ii,3) /* get the dsn */ if Pos(".SPFLOG",dsn)>0 then do /* is it an SPFLOG ? */ qual = "E"today".T"Right(time("S"),5,0) /* specify NOW */ newname = "'"front"."qual"'" /* specify when-saved */ call BA_BUILD_NEW_DS /* build and copy data -*/ if sw.0NOPRINT then iterate call BC_PRINT /* disabled -*/ end /* SPFLOG */ end /* NONVSAM */ end /* ii */ call BB_SEND_MSG /* -*/ return /*@ B_WALK_CATALOG */ /* Allocate a new dataset and copy the old one over. This will cause the data to become eligible for back-up. . ----------------------------------------------------------------- */ BA_BUILD_NEW_DS: /*@ */ if branch then call BRANCH address TSO if monitor then orig = Msg("ON") else orig = Msg("OFF") vba125.0 = "NEW CATALOG UNIT(SYSDA) SPACE(5 5) TRACKS", "RECFM(V B A) LRECL(125) BLKSIZE(9076)" vba125.1 = "MOD" /* if it already exists... */ tempstat = Sysdsn(newname) = "OK" /* 1=exists, 0=missing */ "ALLOC FI(SYSUT2) DA("newname") REU" vba125.tempstat "ALLOC FI(SYSUT1) DA('"dsn"') SHR REU" /* ...and copy the data */ "REPRO INFILE(SYSUT1) OUTFILE(SYSUT2)" "FREE FI(SYSUT1 SYSUT2)" "HBACKDS" newname /* don't rely on the system */ if rc = 0 then "DELETE '"dsn"'" /* burn your bridges */ parse value conf.0+1 exec_name "copied" dsn "to" newname with, $zz$ conf.$zz$ 1 conf.0 . restore = Msg(orig) return /*@ BA_BUILD_NEW_DS */ /* . ----------------------------------------------------------------- */ BB_SEND_MSG: /*@ */ if branch then call BRANCH address TSO if conf.0 > 0 then do /* messages to be sent */ rc = Outtrap("XMIT.") "ALLOC FI($TMP) NEW DELETE REU UNIT(SYSDA) SPACE(1 1) TRACKS", "RECFM(F B) LRECL(80) BLKSIZE(0)" "EXECIO" conf.0 "DISKW $TMP (STEM CONF. FINIS" "TRANSMIT" node"."Userid() "MSGFILE($TMP) NOL NON NOP NOE" "FREE FI($TMP)" rc = Outtrap("OFF") end /* conf.0 */ return /*@ BB_SEND_MSG */ /* This routine has been disabled. . ----------------------------------------------------------------- */ BC_PRINT: /*@ */ return if branch then call BRANCH address TSO if via_vps then, /* using a VPS printer */ "PRT '"newname"' ON" prdest else do /* not a VPS printer */ parse var prdest "TSH" prtid /* K310V perhaps */ prtcmd = "XEROX"Left(prtid,2) /* XEROXK3 maybe */ (prtcmd) "'"newname"' LAND" end /* not VPS */ return /*@ BC_PRINT */ /* . ----------------------------------------------------------------- */ LOCAL_PREINIT: /*@ customize opts */ address TSO return /*@ LOCAL_PREINIT */ /* . ----------------------------------------------------------------- */ HELP: /*@ */ address TSO;"CLEAR" if helpmsg <> "" then do ; say helpmsg; say ""; end ex_nam = Left(exec_name,8) /* predictable size */ say " "ex_nam" Save user ISPF log dataset to a timestamped DSN, " say " and HBACKDS for safekeeping. " say " " say " " say " Syntax: "ex_nam" " /* say " " say " " */ say " " /* say " is the name of the printer to receive " say " any hardcopy produced. If not specified, " say " the dataset will be backed up but not " say " printed. " say " " say " specifies that the printer is a VPS (line) " say " printer. " */ say " orders" ex_nam "to merge the current LOG " say " file with the cumulative monthly file if " say " such exists. The cumulative monthly file " say " will be created if necessary. " "NEWSTACK"; pull; "DELSTACK"; "CLEAR" say " Debugging tools provided include:" say " " say " MONITOR: displays key information throughout processing." say " Displays most paragraph names upon entry." say " " say " BRANCH: show all paragraph entries." say " " say " TRACE tv: will use value following TRACE to place" say " the execution in REXX TRACE Mode." say " " say " " say " Debugging tools can be accessed in the following manner:" say " " say " TSO" exec_name" parameters (( debug-options" say " " say " For example:" say " " say " TSO" exec_name " (( MONITOR TRACE ?R" address ISPEXEC "CONTROL DISPLAY REFRESH" exit /*@ HELP */ /* . ----------------------------------------------------------------- */ BRANCH: Procedure expose, /*@ */ sigl exec_name rc = trace("O") /* we do not want to see this */ arg brparm . $a#y = sigl /* where was I called from ? */ do $b#x = $a#y to 1 by -1 /* inch backward to label */ if Right(Word(Sourceline($b#x),1),1) = ":" then do parse value sourceline($b#x) with $l#n ":" . /* Paragraph */ leave ; end /* name */ end /* $b#x */ select when brparm = "NAME" then return($l#n) /* Return full name */ when brparm = "ID" then do /* Return prefix */ parse var $l#n $l#n "_" . /* get the prefix */ return($l#n) end /* brparm = "ID" */ otherwise say left(sigl,6) left($l#n,40) exec_name "Time:" time("L") end /* select */ return /*@ BRANCH */ /* . ----------------------------------------------------------------- */ DUMP_QUEUE: /*@ Take whatever is in stack */ rc = trace("O") /* and write to the screen */ address TSO "QSTACK" /* how many stacks? */ stk2dump = rc - tk_init_stacks /* remaining stacks */ if stk2dump = 0 & queued() = 0 then return say "Total Stacks" rc , /* rc = #of stacks */ "Begin Stacks" tk_init_stacks , /* Stacks present at start */ "Stacks to DUMP" stk2dump do dd = rc to tk_init_stacks by -1 /* empty each one. */ say "Processing Stack #" dd "Total Lines:" queued() do queued();pull line;say line;end /* pump to the screen */ "DELSTACK" /* remove stack */ end /* dd = 1 to rc */ return /*@ DUMP_QUEUE */ /* . ----------------------------------------------------------------- */ KEYWD: Procedure expose info /*@ hide all vars, except info*/ arg kw kw_pos = wordpos(kw,info) /* find where it is, maybe */ if kw_pos = 0 then return "" /* send back a null, not found*/ kw_val = word(info,kw_pos+1) /* get the next word */ info = Delword(info,kw_pos,2) /* remove both */ return kw_val /*@ KEYWD */ /* . ----------------------------------------------------------------- */ KEYPHRS: Procedure expose, /*@ */ info helpmsg exec_name /* except these three */ arg kp wp = wordpos(kp,info) /* where is it? */ if wp = 0 then return "" /* not found */ front = subword(info,1,wp-1) /* everything before kp */ back = subword(info,wp+1) /* everything after kp */ parse var back dlm back /* 1st token must be 2 bytes */ if length(dlm) <> 2 then /* Must be two bytes */ helpmsg = helpmsg "Invalid length for delimiter("dlm") with KEYPHRS("kp")" if wordpos(dlm,back) = 0 then /* search for ending delimiter*/ helpmsg = helpmsg "No matching second delimiter("dlm") with KEYPHRS("kp")" if helpmsg <> "" then call HELP /* Something is wrong */ parse var back kpval (dlm) back /* get everything b/w delim */ info = front back /* restore remainder */ return Strip(kpval) /*@ KEYPHRS */ /* . ----------------------------------------------------------------- */ NOVALUE: /*@ */ say exec_name "raised NOVALUE at line" sigl say " " say "The referenced variable is" condition("D") say " " zsigl = sigl signal SHOW_SOURCE /*@ NOVALUE */ /* . ----------------------------------------------------------------- */ SHOW_SOURCE: /*@ */ call DUMP_QUEUE /* Spill contents of stacks -*/ if sourceline() <> "0" then /* to screen */ say sourceline(zsigl) rc = trace("?R") nop exit /*@ SHOW_SOURCE */ /* . ----------------------------------------------------------------- */ SS: Procedure /*@ Show Source */ arg ssbeg ssend . if ssend = "" then ssend = 10 if \datatype(ssbeg,"W") | \datatype(ssend,"W") then return address TSO "CLEAR" ssend = ssbeg + ssend do ssii = ssbeg to ssend ; say sourceline(ssii) ; end address TSO "CLEAR" return /*@ SS */ /* . ----------------------------------------------------------------- */ SWITCH: Procedure expose info /*@ */ arg kw sw_val = Wordpos(kw,info) > 0 /* exists = 1; not found = 0 */ if sw_val then /* exists */ info = Delword(info,Wordpos(kw,info),1) /* remove it */ return sw_val /*@ SWITCH */ /* . ----------------------------------------------------------------- */ SYNTAX: /*@ */ errormsg = exec_name, "encountered REXX error" rc "in line" sigl":" errortext(rc) say errormsg zsigl = sigl signal SHOW_SOURCE /*@ SYNTAX */ /* Can call TRAPOUT. . ----------------------------------------------------------------- */ TOOLKIT_INIT: /*@ */ address TSO info = Strip(opts,"T",")") /* clip trailing paren */ parse source sys_id how_invokt exec_name DD_nm DS_nm as_invokt, cmd_env addr_spc usr_tokn parse value "" with tv helpmsg . parse value 0 "ISR00000 YES" "Error-Press PF1" with, sw. zerrhm zerralrm zerrsm if SWITCH("TRAPOUT") then do "TRAPOUT" exec_name parms "(( TRACE R" info exit end /* trapout */ if Word(parms,1) = "?" then call HELP /* I won't be back */ "QSTACK" ; tk_init_stacks = rc /* How many stacks? */ parse value SWITCH("BRANCH") SWITCH("MONITOR") SWITCH("NOUPDT") with, branch monitor noupdt . parse value mvsvar("SYSNAME") sysvar("SYSNODE") with, #tk_cpu node . sw.nested = sysvar("SYSNEST") = "YES" sw.batch = sysvar("SYSENV") = "BACK" sw.inispf = sysvar("SYSISPF") = "ACTIVE" parse value KEYWD("TRACE") "O" with tv . tk_globalvars = "tk_globalvars exec_name tv helpmsg sw. zerrhm", "zerralrm zerrsm zerrlm tk_init_stacks branch", "monitor noupdt" call LOCAL_PREINIT /* for more opts -*/ return /*@ TOOLKIT_INIT */