1 /* REXX FLTTBL Cloned from DUMPTBL 960619 to produce a flat
2 version (up to 32K characters wide) of any ISPF
5 Written by Frank Clarke, Oldsmar, FL
12 19960918 fxc added some error-checking
13 19970115 fxc upgrade REXXSKEL from v.960606 to v.970113; add
15 19991231 fxc upgrade REXXSKEL from v.970113 to v.19991109;
16 RXSKLY2K; DECOMM; LRECL reduced from 32K to "min
20 address TSO /* REXXSKEL ver.19991109 */
26 call TOOLKIT_INIT /* conventional start-up -*/
28 info = parms /* to enable parsing */
32 line = line "(( RESTARTED" /* tell the next invocation */
33 "ISPSTART CMD("exec_name line")" /* Invoke ISPF if nec. */
34 exit /* ...and restart it */
40 if \sw.0error_found then,
41 call C_TABLE_OPS /* -*/
42 if \sw.0error_found then,
43 call D_PUMP_TBL /* -*/
47 if sw.restarted then do
54 . ----------------------------------------------------------------- */
56 if branch then call BRANCH
60 parse var info $tn$ . /* table-name required */
62 helpmsg = "Tablename is required."
66 parse value outdsn "FLATTBLS."$tn$ with,
71 call AB_FIND_LIBRARY /* -*/
73 helpmsg = "Table" $tn$ "was not found in ISPTLIB. Please",
74 "restart specifying a library name as shown below."
75 call HELP /* ...and don't come back */
79 if Left(tblds,1) = "'" then tblds = Strip(tblds,,"'")
80 else tblds = Userid()"."tblds
84 . ----------------------------------------------------------------- */
86 if branch then call BRANCH
90 outdsn = KEYWD("OUTPUT")
91 sortseq = KEYWD("SORT")
92 sw.0purge = SWITCH("DELETEBEHIND")
94 parse value KEYWD("ADD") "0" with bytes_to_add .
96 return /*@ AA_KEYWDS */
98 <tblds> was not specified. Locate the table in ISPTLIB.
99 . ----------------------------------------------------------------- */
100 AB_FIND_LIBRARY: /*@ */
101 if branch then call BRANCH
105 "LA ISPTLIB ((STACK LINE"
109 do Words(tliblist) /* each library */
110 parse var tliblist tblds tliblist
111 if Sysdsn("'"tblds"("$tn$")'") = "OK" then return
115 return /*@ AB_FIND_LIBRARY */
117 . ----------------------------------------------------------------- */
119 if branch then call BRANCH
122 call CA_OPEN_TBL /* -*/
123 call CS_SPIN_TBL /* -*/
124 call CZ_DROP_TBL /* -*/
126 return /*@ C_TABLE_OPS */
128 . ----------------------------------------------------------------- */
130 if branch then call BRANCH
133 "LIBDEF ISPTLIB DATASET ID('"tblds"') STACK"
134 "TBSTATS" $tn$ "STATUS1(s1) STATUS2(s2) ROWCURR(rowct)"
136 say "Table" $tn$ "not available."
137 sw.0error_found = "1"; return
139 if s2 = 1 then, /* not open */
140 "TBOPEN " $tn$ "NOWRITE"
143 if sw.0error_found then return
144 "TBQUERY" $tn$ "KEYS(keylist)",
146 parse var keylist "(" keylist ")"
147 parse var nmlist "(" nmlist ")"
148 namelist = keylist nmlist
150 if sortseq <> "" then "TBSORT" $tn$ "FIELDS("sortseq")"
152 return /*@ CA_OPEN_TBL */
154 . Given: <namelist> contains all the defined names for this table.
155 The table has been TOPped.
156 . ----------------------------------------------------------------- */
157 CS_SPIN_TBL: Procedure expose, /*@ hide everything */
158 expose (tk_globalvars), /* except these */
159 $tn$ namelist xefef tblds rows keylist nmlist maxlen
161 if branch then call BRANCH
164 maxlen = 0 /* maximum line length */
166 "TBSKIP" $tn$ "SAVENAME(xvars)"
167 if rc > 0 then leave /* we're done... */
168 line = "" /* set empty */
169 /* add blocks of "var .. varvalue .." */
170 do cx = 1 to Words(namelist)
171 thiswd = Word(namelist,cx)
172 line = line thiswd xefef Value(thiswd) xefef
174 rc = Trace("O"); rc = Trace(cs_tv)
175 parse var xvars "(" xvars ")"
176 /* add a block of "XVARS .. xvarlist .." */
177 line = line "XVARS" xefef xvars xefef
178 /* add blocks of "xvar .. xvarvalue .." */
179 do cx = 1 to Words(xvars)
180 thiswd = Word(xvars,cx)
181 line = line thiswd xefef Value(thiswd) xefef
183 rc = Trace("O"); rc = Trace(cs_tv)
184 maxlen = Max(maxlen,Length(line))
188 lines_in_stack = queued()
189 line = "Contents of" $tn$ "in" tblds,
190 "("lines_in_stack" rows) KEYS("keylist") NAMES("nmlist")."
191 push line /* make it the first line */
192 maxlen = Max(maxlen,Length(line))
193 if monitor then say "Maximum line length is" maxlen
195 return /*@ CS_SPIN_TBL */
197 . ----------------------------------------------------------------- */
199 if branch then call BRANCH
202 if s2 = 1 then, /* table was not open at start*/
205 return /*@ CZ_DROP_TBL */
207 . ----------------------------------------------------------------- */
209 if branch then call BRANCH
215 maxlen = maxlen + 4 + bytes_to_add /* set LRECL */
216 vbmax.0 = "NEW CATALOG UNIT(SYSDA) SPACE(1 5) TRACKS",
217 "RECFM(V B) LRECL("maxlen") BLKSIZE(0)"
218 vbmax.1 = "SHR" /* if it already exists... */
220 tempstat = Sysdsn(outdsn) = "OK" /* 1=exists, 0=missing */
221 "ALLOC FI($TMP) DA("outdsn") REU" vbmax.tempstat
223 "EXECIO" queued() "DISKW $TMP (FINIS"
227 if rcx = 0 & sw.0purge then do
229 "LIBDEF ISPTLIB DATASET ID('"tblds"') STACK"
231 if rc = 0 then say $tn$ "was deleted"
235 return /*@ D_PUMP_TBL */
237 . ----------------------------------------------------------------- */
238 LOCAL_PREINIT: /*@ customize opts */
239 if branch then call BRANCH
243 return /*@ LOCAL_PREINIT */
245 . ----------------------------------------------------------------- */
248 if helpmsg <> "" then do ; say helpmsg; say ""; end
249 ex_nam = Left(exec_name,8) /* predictable size */
250 say " "ex_nam" produces a flattened version of any ISPF table "
251 say " into a VB-form dataset of minimum necessary LRECL."
253 say " The field contents are written in KEYPHRS format "
254 say " (var .. varval ..) "
255 say " key-fields first, followed by name-fields, followed by the "
256 say " names of any extension variables key-phrased by 'XVARS', "
257 say " followed by the extension variables themselves in KEYPHRS "
260 say " The first record on the file identifies the table name, the "
261 say " source library, the number of rows processed, and the key- and "
267 say " Syntax: "ex_nam" <tbl> (Required)"
269 say " <OUTPUT outdsn> (Defaults)"
270 say " <SORT sortspec> "
271 say " <ADD bytes> (Defaults)"
273 say " <tbl> identifies the table to be dumped. "
275 say " <libdsn> identifies the ISPF Table library which holds <tbl>."
276 say " If <libdsn> is not specified, ISPTLIB will be "
277 say " searched to find the correct dataset. "
279 say " <outdsn> (default: FLATTBLS.<tbl>) names the output file. "
280 say " <outdsn> will be created if it does not exist. "
282 say " <sortspec> causes the table to be sorted as indicated before "
283 say " being dumped. "
285 say " <bytes> (default=0) causes the LRECL of the output dataset "
286 say " to be extended to enable updating. "
289 say " Debugging tools provided include: "
291 say " MONITOR: displays key information throughout processing. "
292 say " Displays most paragraph names upon entry. "
294 say " NOUPDT: by-pass all update logic. "
296 say " BRANCH: show all paragraph entries. "
298 say " TRACE tv: will use value following TRACE to place the "
299 say " execution in REXX TRACE Mode. "
302 say " Debugging tools can be accessed in the following manner: "
304 say " TSO "ex_nam" parameters (( debug-options "
308 say " TSO "ex_nam" vt2231 add 17 (( MONITOR TRACE ?R "
309 address ISPEXEC "CONTROL DISPLAY REFRESH"
311 /* REXXSKEL back-end removed for space */