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