/* REXX CMFLTTBL Cloned from DUMPTBL 960619 to produce a flat version (up to 32K characters wide) of any ISPF table. Use CMRSTTBL to reload this data as an ISPF table. Written by Frank Clarke, Oldsmar, FL Impact Analysis . SYSEXEC LA . SYSEXEC TRAPOUT Modification History 19960918 fxc added some error-checking 19970115 fxc upgrade REXXSKEL from v.960606 to v.970113; add RESTARTability; 19991231 fxc upgrade REXXSKEL from v.970113 to v.19991109; RXSKLY2K; DECOMM; LRECL reduced from 32K to "min needed"; 20010616 fxc reorganize 20010829 fxc use CLIST TBLSORT in place of TBSORT 20071119 fxc resume direct TBSORT; */ 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 */ if \sw.inispf then do arg line line = line "(( RESTARTED" /* tell the next invocation */ "ISPSTART CMD("exec_name line")" /* Invoke ISPF if nec. */ exit /* ...and restart it */ end call A_INIT /* Initialization -*/ "NEWSTACK" if \sw.0error_found then, call C_TABLE_OPS /* -*/ if \sw.0error_found then, call D_PUMP_TBL /* -*/ "DELSTACK" if sw.0exit_ISPF then do rc = OutTrap("ll.") exit 4 end exit /*@ CMFLTTBL */ /* Initialization . ----------------------------------------------------------------- */ A_INIT: /*@ */ if branch then call BRANCH address TSO xefef = 'EFEF'x call AA_KEYWDS /* -*/ parse var info $tn$ . /* table-name required */ if $tn$ = "" then do helpmsg = "Tablename is required." call HELP end parse value outdsn "FLATTBLS."$tn$ with, outdsn . sepr = mark /* KEYPHRS separator */ if tblds = "" then do call AB_FIND_LIBRARY /* -*/ if tblds = "" then do helpmsg = "Table" $tn$ "was not found in ISPTLIB. Please", "restart specifying a library name as shown below." call HELP /* ...and don't come back */ end end else, if Left(tblds,1) = "'" then tblds = Strip(tblds,,"'") else tblds = Userid()"."tblds return /*@ A_INIT */ /* Parse parameters . ----------------------------------------------------------------- */ AA_KEYWDS: /*@ */ if branch then call BRANCH address TSO tblds = KEYWD("IN") outdsn = KEYWD("OUTPUT") sortseq = KEYWD("SORT") sw.0purge = SWITCH("DELETEBEHIND") parse value KEYWD("MARK") xefef with, mark . if Length(mark) > 2 then mark = x2c(mark) parse value KEYWD("ADD") "0" with bytes_to_add . return /*@ AA_KEYWDS */ /* was not specified. Locate the table in ISPTLIB. . ----------------------------------------------------------------- */ AB_FIND_LIBRARY: /*@ */ if branch then call BRANCH address TSO "NEWSTACK" "LA ISPTLIB ((STACK LINE" pull tliblist "DELSTACK" do Words(tliblist) /* each library */ parse var tliblist tblds tliblist if Sysdsn("'"tblds"("$tn$")'") = "OK" then return end /* tliblist */ tblds = "" return /*@ AB_FIND_LIBRARY */ /* . ----------------------------------------------------------------- */ C_TABLE_OPS: /*@ */ if branch then call BRANCH address ISPEXEC call CA_OPEN_TBL /* make the table ready -*/ call CS_SPIN_TBL /* spool to output queue -*/ call CZ_DROP_TBL /* release table -*/ return /*@ C_TABLE_OPS */ /* . ----------------------------------------------------------------- */ CA_OPEN_TBL: /*@ */ if branch then call BRANCH address ISPEXEC "LIBDEF ISPTLIB DATASET ID('"tblds"') STACK" "TBSTATS" $tn$ "STATUS1(s1) STATUS2(s2) ROWCURR(rowct)" if s1 > 1 then do say "Table" $tn$ "not available." sw.0error_found = "1"; return end; else, if s2 = 1 then, /* not open */ "TBOPEN " $tn$ "NOWRITE" else "TBTOP" $tn$ "LIBDEF ISPTLIB" if sw.0error_found then return "TBQUERY" $tn$ "KEYS(keylist)", "NAMES(nmlist)" parse var keylist "(" keylist ")" parse var nmlist "(" nmlist ")" namelist = keylist nmlist if sortseq <> "" then do "TBSORT" $tn$ "FIELDS(" sortseq ")" end return /*@ CA_OPEN_TBL */ /* . Given: contains all the defined names for this table. The table has been TOPped. . ----------------------------------------------------------------- */ CS_SPIN_TBL: Procedure expose, /*@ hide everything */ expose (tk_globalvars), /* except these */ $tn$ namelist sepr tblds rows keylist nmlist maxlen cs_tv = Trace() if branch then call BRANCH address ISPEXEC maxlen = 0 /* maximum line length */ do forever "TBSKIP" $tn$ "SAVENAME(xvars)" if rc > 0 then leave /* we're done... */ line = "" /* set empty */ /* add blocks of "var .. varvalue .." */ do cx = 1 to Words(namelist) thiswd = Word(namelist,cx) line = line thiswd sepr Value(thiswd) sepr end /* cx */ rc = Trace("O"); rc = Trace(cs_tv) parse var xvars "(" xvars ")" /* add a block of "XVARS .. xvarlist .." */ line = line "XVARS" sepr xvars sepr /* add blocks of "xvar .. xvarvalue .." */ do cx = 1 to Words(xvars) thiswd = Word(xvars,cx) line = line thiswd sepr Value(thiswd) sepr end /* cx */ rc = Trace("O"); rc = Trace(cs_tv) maxlen = Max(maxlen,Length(line)) queue line end /* forever */ lines_in_stack = queued() line = "Contents of" $tn$ "in" tblds, "("lines_in_stack" rows) KEYS("keylist") NAMES("nmlist")." push line /* make it the first line */ maxlen = Max(maxlen,Length(line)) if monitor then say "Maximum line length is" maxlen return /*@ CS_SPIN_TBL */ /* . ----------------------------------------------------------------- */ CZ_DROP_TBL: /*@ */ if branch then call BRANCH address ISPEXEC if s2 = 1 then, /* table was not open at start*/ "TBEND" $tn$ return /*@ CZ_DROP_TBL */ /* Write queue to ; purge table if requested. . ----------------------------------------------------------------- */ D_PUMP_TBL: /*@ */ if branch then call BRANCH address TSO if monitor then say, "Writing text." maxlen = maxlen + 4 + bytes_to_add /* set LRECL */ vbmax.0 = "NEW CATALOG UNIT(SYSDA) SPACE(1 5) TRACKS", "RECFM(V B) LRECL("maxlen") BLKSIZE(0)" vbmax.1 = "SHR" /* if it already exists... */ tempstat = Sysdsn(outdsn) = "OK", /* 1=exists, 0=missing */ | Sysdsn(outdsn) = "MEMBER NOT FOUND" "ALLOC FI($TMP) DA("outdsn") REU" vbmax.tempstat rcx = rc "EXECIO" queued() "DISKW $TMP (FINIS" rcx = max(rcx,rc) "FREE FI($TMP)" if rcx = 0 & sw.0purge then do address ISPEXEC "LIBDEF ISPTLIB DATASET ID('"tblds"') STACK" "TBERASE" $tn$ if rc = 0 then say $tn$ "was deleted" "LIBDEF ISPTLIB" end return /*@ D_PUMP_TBL */ /* . ----------------------------------------------------------------- */ LOCAL_PREINIT: /*@ customize opts */ if branch then call BRANCH address TSO sw.0exit_ISPF = SWITCH("RESTARTED") return /*@ LOCAL_PREINIT */ /* . ----------------------------------------------------------------- */ HELP: /*@ */ address TSO;"CLEAR" ; say "" if helpmsg <> "" then do ; say helpmsg; say ""; end ex_nam = Left(exec_name,8) /* predictable size */ say " "ex_nam" produces a flattened version of any ISPF table into a " say " VB-form dataset of the minimum necessary LRECL. " say " " say " The field contents are written in KEYPHRS format " say " (var .. varval ..) " say " key-fields first, followed by name-fields, followed by the names of any" say " extension variables key-phrased by 'XVARS', followed by the extension " say " variables themselves in KEYPHRS format. " say " " say " The first record on the file identifies the table name, the source " say " library, the number of rows processed, and the key- and name-fields. " say " " say " Syntax: "ex_nam" (Required)" say " " say " (Defaults)" say " " say " " say " (Defaults)" say " (Defaults)" say " " say " more.... " "NEWSTACK"; pull ; "CLEAR" ; "DELSTACK" say " identifies the table to be dumped. " say " " say " identifies the ISPF Table library which holds ." say " If is not specified, ISPTLIB will be " say " searched to find the correct dataset. " say " " say " (default: FLATTBLS.) names the output file. " say " will be created if it does not exist. " say " " say " causes the table to be sorted as indicated before " say " being dumped. " say " " say " signals that, after dumping the table " say " contents, the original table is to be purged. " say " " say " (default='EFEF'x) is a two-character separator to be" say " placed between tokens for use by KEYPHRS. If a " say " 4-character string is specified here, it will be " say " assumed to be a valid hexadecimal string and will be" say " converted to its 2-character form. Specifying an " say " invalid hex string will cause unpredictable results." say " " say " (default=0) causes the LRECL of the output dataset " say " to be extended to enable updating. " "NEWSTACK"; pull ; "CLEAR" ; "DELSTACK" 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" vt2231 add 17 (( 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 . 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") "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 */