/* REXX PDS2SEQ Convert a PDS to a sequential dataset either for printing or for edit/IEBUPDTE restore. Use '(routine name) ?' for HELP-text. Written by Frank Clarke in the Dark Ages Rebuilt by Frank Clarke, rexxhead@yahoo.com, 19991230 Impact Analysis . SYSEXEC DIRSTATS . SYSEXEC SYSUMON . SYSEXEC TRAPOUT Modification History 20210530 fxc make it work for PDS-Es; collect stats and annotate each member with stats where they exist; 20211012 fxc align stats 20230401 fxc SYSUMON only if not testing 20230724 fxc modernize logging; enable NOLOG; 20230726 fxc adjust HELP; 20230729 fxc clip long lines; 20230805 fxc belay using MEMBERS since we already collect member data via DIRSTATS; 20230806 fxc chg SYSPROC to SYSEXEC in Impact Analysis; 20230810 fxc set msglim based on screen width; */ arg argline address TSO /* REXXSKEL ver.19991109 */ arg parms "((" opts signal on syntax signal on novalue call TOOLKIT_INIT /* conventional start-up -*/ rc = trace(tv) info = parms /* to enable parsing */ call A_INIT /* -*/ if sw.0error_found then nop ; else, call B_TRANSFER /* -*/ if sw.0Nolog = 0 then , /* not set */ call ZB_SAVELOG /* -*/ if \sw.nested then call DUMP_QUEUE /* -*/ exit /*@ PDS2SEQ */ /* . ----------------------------------------------------------------- */ A_INIT: /*@ */ if branch then call BRANCH address TSO if tv = 'N' then, /* only if not testing */ "SYSUMON USER" Userid() "TOOL" exec_name call AA_SETUP_LOG /* -*/ call AK_KEYWDS /* -*/ parse value "" with, mbrlist parse value "0 0 0 0 0 0 0 0" with, ct. . parse var info dsname info if dsname = "" then, helpmsg = helpmsg " Input DSName was not specified." if info <> "" then, helpmsg = helpmsg " Unrecognized parameters: >"info"<" if helpmsg <> "" Then call HELP /* ...and don't come back */ if Left(dsname,1) = "'" then, dsname = Strip(dsname,,"'") /* unquoted */ else, dsname = Userid()"."dsname /* fully-qualified */ return /*@ A_INIT */ /* . ----------------------------------------------------------------- */ AA_SETUP_LOG: /*@ */ if branch then call BRANCH address TSO msglim = SYSVAR( "SYSWTERM" ) - 12 parse value "0 0 0 0 0" with, log# log. . parse value Date("S") Time("S") Time("N") with, yyyymmdd sssss hhmmss . hhmmss = Space( Translate( hhmmss,' ',':' ) ,0 ) parse var yyyymmdd 4 yrdigit 5 mm 7 dd /* 9 12 14 maybe */ if Pos(yrdigit,"13579") > 0 then mm = mm + 12 /* mm=24 */ logtag = Substr("ABCDEFGHIJKLMNOPQRSTUVWX",mm,1) /* logtag=X */ subid = logtag""dd""Left( hhmmss,4 ) /* X141743 ? */ vb4k.0 = "NEW CATALOG UNIT(SYSDA) SPACE(1 5) TRACKS", "RECFM(V B) LRECL(4096) BLKSIZE(0)" vb4k.1 = "SHR" /* if it already exists... */ logdsn = "@LOG."exec_name"."subid".LIST" logpref = "("Branch( "ID" )")" call ZL_LOGMSG( logpref, exec_name "started by" Userid() yyyymmdd hhmmss) return /*@ AA_SETUP_LOG */ /* . ----------------------------------------------------------------- */ AK_KEYWDS: /*@ */ if branch then call BRANCH address TSO parse value "0" with, stats. parse value KEYWD( "OUTPUT" ) "PDS2SEQ.DATA" with, outdsn . logpref = "("Branch( "ID" )")" call ZL_LOGMSG( logpref "OUTPUT set to" outdsn ) parse value KEYWD( "FOR" ) "EDIT" with, purpose . call ZL_LOGMSG( logpref "PURPOSE set to" purpose ) sw.0Nolog = SWITCH( "NOLOG" ) sw.0DoStats = SWITCH( "STATS" ) call ZL_LOGMSG( logpref "STATS="sw.0DoStats ) fmbr = KEYWD( "FROM" ) tmbr = KEYWD( "TO" ) fmbrl = Max(Length(fmbr),1) tmbrl = Max(Length(tmbr),1) return /*@ AK_KEYWDS */ /* All the tasks associated with making the 'input' output. . ----------------------------------------------------------------- */ B_TRANSFER: /*@ */ if branch then call BRANCH address TSO call BA_GET_MEMBERS /* -*/ if sw.0error_found then return call BB_ALLOC_OUTPUT /* -*/ if sw.0error_found then return do Words(mbrlist) /* every member */ parse var mbrlist mbr mbrlist /* isolate */ if CERTIFY(mbr) then do /* transfer text -*/ logpref = "("Branch( "ID" )")" call ZL_LOGMSG( logpref "Selected" mbr ) "NEWSTACK" call BC_EXECIO /* -*/ "DELSTACK" end /* CERTIFY */ else do /* rejected */ logpref = "("Branch( "ID" )")" call ZL_LOGMSG( logpref "Rejected" mbr ) end end /* words(mbrlist) */ "EXECIO 0 DISKW OUT (FINIS" /* close output */ "FREE FI($IN OUT)" logpref = "("Branch( "ID" )")" call ZL_LOGMSG( logpref ct.0Writes "lines written to output" ) return /*@ B_TRANSFER */ /* Obtain a list of members. . ----------------------------------------------------------------- */ BA_GET_MEMBERS: /*@ */ if branch then call BRANCH address TSO "NEWSTACK" "DIRSTATS" "'"dsname"'" do queued() pull line parse var line mbr stats mbrlist = mbrlist mbr parse value stats with, stats.mbr end /* queued */ "DELSTACK" return /*@ BA_GET_MEMBERS */ /* Prepare the output dataset. . ----------------------------------------------------------------- */ BB_ALLOC_OUTPUT: /*@ */ if branch then call BRANCH address TSO ldrc = Listdsi("'"dsname"' directory norecall") parse var sysrecfm form 2 if purpose = "PRINT" then, recfm = form "B A" else recfm = form "B" msgstat = Msg("OFF") "FREE FI(OUT)" ; "DELETE" outdsn rc = Msg(msgstat) /* restore */ if sysunits = "BLOCK" then sysunits = "TRACKS" if sysused = "N/A" then sysused = 3 "ALLOC FI(OUT) DA("outdsn") NEW CATALOG REU UNIT(SYSDA)", sysunits "SPACE("sysused sysseconds") BLKSIZE(0)", "RECFM("recfm") LRECL("syslrecl")" return /*@ BB_ALLOC_OUTPUT */ /* Get input data; modify as necessary; add header info; write. . ----------------------------------------------------------------- */ BC_EXECIO: /*@ */ if branch then call BRANCH address TSO if noupdt then return /* don't read or write */ "ALLOC FI($IN) DA('"dsname"("mbr")') SHR REU" "EXECIO * DISKR $IN (FINIS" if purpose = "EDIT" then do if stats.mbr <> "STATS?" then, if sw.0DoStats then push "< "Strip(stats.mbr)" >" push "./ REPL NAME="mbr /* IEBUPDTE header */ end /* EDIT */ else do /* PRINT */ do queued() parse pull line; queue " "line end push " "; push "1" dsname"("mbr")" end /* PRINT */ ct.0Writes = ct.0Writes + queued() /* total writes */ "EXECIO" queued() "DISKW OUT" /* not FINIS... */ return /*@ BC_EXECIO */ /* Is this member one we should process? . ----------------------------------------------------------------- */ CERTIFY: Procedure expose, /*@ */ (tk_globalvars) fmbr tmbr fmbrl tmbrl mbr if branch then call BRANCH address TSO valid = "1" if fmbr <> "" then, if fmbr > Left(mbr,fmbrl) then valid = "0" if tmbr <> "" then, if tmbr < Left(mbr,tmbrl) then valid = "0" return(valid) /*@ CERTIFY */ /* . ----------------------------------------------------------------- */ LOCAL_PREINIT: /*@ customize opts */ address TSO return /*@ LOCAL_PREINIT */ /* . ----------------------------------------------------------------- */ ZB_SAVELOG: /*@ */ if branch then call BRANCH address TSO if Symbol("LOG#") = "LIT" then return /* not yet set */ "ALLOC FI($LOG) DA("logdsn") REU" vb4k.0 "EXECIO" log# "DISKW $LOG (STEM LOG. FINIS" "FREE FI($LOG)" return /*@ ZB_SAVELOG */ /* . ----------------------------------------------------------------- */ ZL_LOGMSG: Procedure expose, /*@ */ (tk_globalvars) log. log# msglim rc = Trace("O") address TSO parse arg msgtext /* for making the msgline always reasonably short: */ do while Length(msgtext) > msglim pt = LastPos(" ",msgtext,msglim) slug = Left(msgtext,pt) parse value log#+1 slug with, zz log.zz 1 log# . if monitor then say, log.zz msgtext = " "Substr(msgtext,pt) end /* while msglim */ parse value log#+1 msgtext with, zz log.zz 1 log# . if monitor then say, log.zz return /*@ ZL_LOGMSG */ /* . ----------------------------------------------------------------- */ HELP: /*@ */ address TSO;"CLEAR" if helpmsg <> "" then say ""; say helpmsg ex_nam = Left(exec_name,8) /* predictable size */ say " " say " "ex_nam" Convert a PO dataset to PS for printing or batch update. " say " " say " Syntax: "ex_nam" dsname (Required)" say " OUTPUT outdsn (Defaults)" say " FOR purpose (Defaults)" say " FROM fr-mbr " say " TO to-mbr " say " NOLOG " say " STATS " say " " say " dsname identifies the PO dataset which is to be converted. " say " " say " outdsn identifies the output dataset. If not specified, it" say " defaults to 'PDS2SEQ.DATA'. " say " " say " purpose may be either 'EDIT' or 'PRINT'. If not specified, " say " the default is 'EDIT'. " say " " say " more...... " "NEWSTACK"; pull; "CLEAR"; "DELSTACK" say " " say " fr-mbr if specified, identifies the first member to be " say " written to the output. 'fr-mbr' may be a partial " say " membername. If, for instance, 'fr-mbr' is 'BT' the " say " first member whose name begins with 'BT' will be " say " selected even if the membername is longer. Prior " say " members will not be selected. " say " " say " If 'fr-mbr' is not specified, selection begins with " say " the first member. " say " " say " to-mbr if specified, identifies the last member to be " say " written to the output. 'to-mbr' may be a partial " say " membername. If, for instance, 'to-mbr' is 'TB' the " say " last member whose name begins with 'TB' will be " say " selected even if the membername is longer. Later " say " members will not be selected. " say " " say " If 'to-mbr' is not specified, selection ends with " say " the last member. " "NEWSTACK"; pull; "CLEAR"; "DELSTACK" say " " say " NOLOG suppresses the production of the log file. " say " " say " STATS directs that member statistics, where they exist, " say " are to be annotated as the first line of each " say " member. " "NEWSTACK"; pull; "CLEAR"; "DELSTACK" say " " say " Debugging tools provided include: " say " " say " MONITOR displays key information throughout processing. " say " Displays most paragraph names upon entry. " say " " say " NOUPDT by-pass all update logic. " say " " say " BRANCH show all paragraph entries. " say " " say " TRACE tv will use value following TRACE to place the execution in" say " REXX TRACE Mode. " say " " say " " say " Debugging tools can be accessed in the following manner: " say " " say " TSO "ex_nam" parameters (( debug-options " say " " say " For example " say " " say " TSO "ex_nam" (( MONITOR TRACE ?R " if sysvar("SYSISPF") = "ACTIVE" then, 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 . origin = sigl /* where was I called from ? */ do currln = origin to 1 by -1 /* inch backward to label */ if Right(Word(Sourceline(currln),1),1) = ":" then do parse value sourceline(currln) with pgfname ":" . /* Label */ leave ; end /* name */ end /* currln */ select when brparm = "NAME" then return(pgfname) /* Return full name */ when brparm = "ID" then do /* wants the prefix */ parse var pgfname pgfpref "_" . /* get the prefix */ return(pgfpref) end /* brparm = "ID" */ otherwise say left(sigl,6) left(pgfname,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 ssend = ssbeg + ssend do ssii = ssbeg to ssend ; say sourceline(ssii) ; end 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") "N" 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 */