File Edit Confirm Menu Utilities Compilers Test Help
-------------------------------------------------------------------------------
EDIT JIM.REXX(VC) - 01.06 Columns 00009 00080
Command ===> Scroll ===> CSR
****** ***************************** Top of Data ******************************
000001 /*------------------- REXX -----------------------------------*
000002 * *
000003 * This code does not do anything other than display the *
000004 * IDCAMS control statement needed to define a VSAM file. *
000005 * *
000006 * From ISPF 3.4, type VC next to a VSAM data set *
000007 * *
000008 * Written by Jim Connelley. No copyright. Ifyawanna, (If *
000009 * you want to) send your enhancements to jim@connelley.org *
000010 * *
000011 * There are bugs, such as handling multi-volume files, but *
000012 * that's where YOU come in. *
000013 * *
000014 * This code makes use of a handy command called STEMVIEW *
000015 * written by Gilbert Saint-flour available as source code *
000016 * as part of file # 183 at http://www.cbttape.org *
000017 * *
000018 *------------------------------------------------------------*
000019 */
000020 Parse Arg data_set_name
000021 Address tso
000022 Call init_variables
000023 Call execute_listcat
000024 Call process_listcat
000025 indent = copies(' ',5)
000026 Call addkey ")" /* add closing paren */
000027 out_line.0 = x /* set total linecount */
000028 Call output_results
000029 Exit 0
000030
000031 /*------------------------------------------------------------*
000032 * *
000033 * process_listcat drives the processing of the LISTCAT *
000034 * output. *
000035 * *
000036 *------------------------------------------------------------*
000037 */
000038 process_listcat:
000039 Do i = 1 To trap_line.0
000040 Parse Var trap_line.i field1 the_rest
000041 Select
000042 When field1 = 'NONVSAM' Then Do
000043 out_line.0 = 1 /* set one line */
000044 out_line.1 = "Not a VSAM data set:" data_set_name
000045 Call output_results
000046 Exit 0
000047 End
000048 When field1 = 'CLUSTER' Then Do
000049 big_state = 'CLUSTER'
000050 Parse Var the_rest . object_name
000051 x = 1
000052 out_line.x = indent "DEFINE"
000053 Call addkey "CLUSTER ("
000054 indent = copies(' ',5)
000055 Call addkey "NAME(" || object_name || ")"
000056 indent = copies(' ',10)
000057 Call addkey "INDEXED" /* KLUDGE default LINE 4 */
000058 Call addkey "SHAREOPTION(2 1)" /* KLUDGE default LINE 5 */
000059 End
000060 When field1 = 'DATA' Then Do
000061 big_state = 'DATA'
000062 Parse Var the_rest . data_name
000063 indent = copies(' ',5)
000064 Call addkey ")"
000065 indent = copies(' ',1)
000066 Call addkey "DATA("
000067 indent = copies(' ',5)
000068 Call addkey "NAME(" || data_name || ")"
000069 indent = copies(' ',10)
000070 End
000071 When field1 = 'INDEX' Then Do
000072 big_state = 'INDEX'
000073 Parse Var the_rest . index_name
000074 indent = copies(' ',5)
000075 Call addkey ")"
000076 indent = copies(' ',1)
000077 Call addkey "INDEX("
000078 indent = copies(' ',5)
000079 Call addkey "NAME(" || index_name || ")"
000080 indent = copies(' ',10)
000081 End
000082 When field1 = 'HISTORY' Then Do
000083 state = 'HISTORY'
000084 End
000085 When field1 = 'SMSDATA' Then Do
000086 state = 'SMSDATA'
000087 End
000088 When field1 = 'RLSDATA' Then Do
000089 state = 'RLSDATA'
000090 End
000091 When field1 = 'ASSOCIATIONS' Then Do
000092 state = 'ASSOCIATIONS'
000093 End
000094 When field1 = 'ATTRIBUTES' Then Do
000095 state = 'ATTRIBUTES'
000096 End
000097 When field1 = 'STATISTICS' Then Do
000098 state = 'STATISTICS'
000099 End
000100 When field1 = 'ALLOCATION' Then Do
000101 state = 'ALLOCATION'
000102 End
000103 When field1 = 'VOLUME' Then Do
000104 state = 'VOLUME'
000105 End
000106 Otherwise
000107 Select
000108 When state = 'SMSDATA' Then Do
000109 Call do_smsdata
000110 End
000111 When state = 'ATTRIBUTES' Then Do
000112 Call do_attributes
000113 End
000114 When state = 'ALLOCATION' Then Do
000115 Call do_allocation
000116 End
000117 When state = 'VOLUME' Then Do
000118 Call do_volume
000119 End
000120 Otherwise
000121 Nop
000122 End /* Select state */
000123 End /* Select field1 */
000124 End
000125
000126 Return
000127
000128 /*------------------------------------------------------------*
000129 * *
000130 * do_smsdata processes the keywords found under the SMSDATA *
000131 * section of output from listcat command. *
000132 * *
000133 *------------------------------------------------------------*
000134 */
000135 do_smsdata:
000136
000137 keyval = getkey('STORAGECLASS' trap_line.i)
000138 If keyval /= '' Then
000139 Call addkey "STORAGECLASS(" || keyval || ")"
000140
000141 keyval = getkey('MANAGEMENTCLASS' trap_line.i)
000142 If keyval /= '' Then
000143 Call addkey "MANAGEMENTCLASS(" || keyval || ")"
000144
000145 keyval = getkey('DATACLASS' trap_line.i)
000146 If keyval /= '' Then
000147 Call addkey "DATACLASS(" || keyval || ")"
000148
000149 keyval = getkey('BWO----' trap_line.i)
000150 If keyval /= '' Then
000151 Call addkey "BWO(" || keyval || ")"
000152
000153 Return
000154
000155 /*------------------------------------------------------------*
000156 * *
000157 * do_volume processes the keywords and values found under *
000158 * under the volume section of the LISTCAT command. *
000159 * Currently, we are only interested in the VOLUME keyword. *
000160 * *
000161 *------------------------------------------------------------*
000162 */
000163 do_volume:
000164
000165 keyval = getkey('VOLSER' trap_line.i)
000166 If keyval /= '' Then
000167 Call addkey "VOLUMES(" || keyval || ")"
000168
000169 Return
000170
000171 /*------------------------------------------------------------*
000172 * *
000173 * do_allocation processes the keywords and values found *
000174 * under the allocation section of the LISTCAT command. *
000175 * *
000176 *------------------------------------------------------------*
000177 */
000178 do_allocation:
000179
000180 keyval = getkey('SPACE-TYPE' trap_line.i)
000181 If keyval /= '' Then
000182 space_type = keyval
000183
000184 keyval = getkey('SPACE-PRI' trap_line.i)
000185 If keyval /= '' Then
000186 space_pri = keyval
000187
000188 keyval = getkey('SPACE-SEC' trap_line.i)
000189 If keyval /= '' Then
000190 Call addkey space_type || "(" || space_pri keyval || ")"
000191
000192 Return
000193
000194 /*------------------------------------------------------------*
000195 * *
000196 * do_attributes process the non-default data under the *
000197 * ATTRIBUTES section of output from the LISTCAT command. *
000198 * *
000199 *------------------------------------------------------------*
000200 */
000201 do_attributes:
000202
000203 If big_state = 'DATA' Then
000204 Call do_attributes_data
000205
000206 If big_state = 'INDEX' Then
000207 Call do_attributes_index
000208
000209 keyval = getkey('BUFSPACE' trap_line.i)
000210 If keyval /= '' Then
000211 Call addkey "BUFFERSPACE(" || keyval || ")"
000212
000213 keyval = getkey('EXCPEXIT' trap_line.i)
000214 If keyval /= '' Then
000215 Call addkey "EXCEPTIONEXIT(" || keyval || ")"
000216
000217 keyval = getkey('CISIZE' trap_line.i)
000218 If keyval /= '' Then
000219 Call addkey "CONTROLINTERVALSIZE(" || keyval || ")"
000220
000221 position = pos('SHROPTNS',trap_line.i)
000222 If position /= 0 Then Do
000223 position = position + length('SHROPTNS(')
000224 keyval = substr(trap_line.i,position,3)
000225 out_line.5 = indent "SHAREOPTIONS(" || keyval || ") -"
000226 End
000227
000228 Call findkey "WRITECHECK"
000229 Call findkey "REUSE"
000230
000231 If wordpos("NONINDEXED",trap_line.i) /= 0 Then
000232 out_line.4 = indent "NONINDEXED -"
000233 If wordpos("NUMBERED",trap_line.i) /= 0 Then
000234 out_line.4 = indent "NUMBERED -"
000235 If wordpos("LINEAR",trap_line.i) /= 0 Then
000236 out_line.4 = indent "LINEAR -"
000237
000238 Return
000239
000240 /*------------------------------------------------------------*
000241 * *
000242 * do_attributes_data processes those keywords that are *
000243 * only valid for the data portion of a cluster. . *
000244 * Currently these are KEYS(), RECORDSIZE(), erase and speed. *
000245 * *
000246 *------------------------------------------------------------*
000247 */
000248 do_attributes_data:
000249
000250 keyval = getkey('KEYLEN' trap_line.i)
000251 If keyval /= '' Then
000252 keylen = keyval
000253
000254 keyval = getkey('RKP' trap_line.i)
000255 If keyval /= '' Then
000256 Call addkey "KEYS(" || keylen keyval || ")"
000257
000258 keyval = getkey('AVGLRECL' trap_line.i)
000259 If keyval /= '' Then
000260 avglrecl = keyval
000261
000262 keyval = getkey('MAXLRECL' trap_line.i)
000263 If keyval /= '' Then
000264 Call addkey "RECORDSIZE(" || avglrecl keyval || ")"
000265
000266 Call findkey "ERASE"
000267 Call findkey "SPEED"
000268
000269 Return
000270
000271 /*------------------------------------------------------------*
000272 * *
000273 * do_attributes_index processes those keywords that are *
000274 * only valid for the index portion of a cluster. *
000275 * Currently these are REPLICATE and INBED. *
000276 * *
000277 *------------------------------------------------------------*
000278 */
000279 do_attributes_index:
000280 Call findkey "REPLICATE"
000281 Call findkey "IMBED"
000282 Return
000283
000284 /*------------------------------------------------------------*
000285 * *
000286 * getkey function scans a passed string for a *
000287 * specific keyword. If the keyword is found, getkey *
000288 * returns a value associated with the keyword. *
000289 * *
000290 * getkey is oriented to that ugly listcat output such as: *
000291 * STORAGECLASS -----SCPRIM *
000292 * example: *
000293 * getkey('STORAGECLASS','STORAGECLASS -----SCPRIM') *
000294 * *
000295 * getkey will return SCPRIM *
000296 * *
000297 *------------------------------------------------------------*
000298 */
000299 getkey: procedure
000300 Parse Arg keyword str
000301 ret_str = ''
000302 position = pos(keyword,str)
000303 If position /= 0 Then Do
000304 len = length(keyword)
000305 position = position + len
000306 len = 24 - len
000307 ret_str = strip(strip(substr(str,position,len)),,'-')
000308 If ret_str = '(NULL)' Then ret_str = ''
000309 End
000310 Return ret_str
000311
000312 /*------------------------------------------------------------*
000313 * *
000314 * findkey scans for a passed string and if it is found, *
000315 * adds the same string to the DEFINE statement. *
000316 * *
000317 *------------------------------------------------------------*
000318 */
000319 findkey:
000320 Parse Arg keyword
000321 If wordpos(keyword,trap_line.i) /= 0 Then
000322 Call addkey keyword
000323 Return
000324
000325 /*------------------------------------------------------------*
000326 * *
000327 * addkey procedure simply adds a passed value to the *
000328 * DEFINE statement that we are building. *
000329 * *
000330 * Put a check here for keywords such as recordsize(0 0) *
000331 * Return if found, because IDCAMS rejects such values *
000332 * as being 'out of range'. *
000333 * *
000334 *------------------------------------------------------------*
000335 */
000336 addkey: procedure expose out_line. x indent
000337 Parse Arg keyword
000338 length_keyword = length(keyword)
000339 If length_keyword > 3 Then
000340 If substr(keyword,length_keyword-2,3) = '(0)' Then
000341 Return
000342 If length_keyword > 5 Then
000343 If substr(keyword,length_keyword-4,5) = '(0 0)' Then
000344 Return
000345 out_line.x = out_line.x "-"
000346 x = x + 1
000347 out_line.x = indent keyword
000348 Return
000349
000350 /*------------------------------------------------------------*
000351 * *
000352 * execute_listcat calls listcat command and handles return. *
000353 * *
000354 *------------------------------------------------------------*
000355 */
000356 execute_listcat:
000357 data_set_name = strip(data_set_name,,"'")
000358 x = outtrap('trap_line.')
000359 "listcat entry('" || data_set_name || "') all"
000360 If RC /= 0 Then Do
000361 out_line.0 = 1 /* set one line */
000362 out_line.1 = "listcat RC:" RC
000363 Call output_results
000364 Exit 0
000365 End
000366 x = outtrap('off')
000367 If DATATYPE(trap_line.0) /= 'NUM' Then Do
000368 out_line.0 = 1 /* set one line */
000369 out_line.1 = "listcat No output trapped"
000370 Call output_results
000371 Exit 0
000372 End
000373 Return
000374
000375 /*------------------------------------------------------------*
000376 * *
000377 * init_variables is coded promarily so we can add comments *
000378 * about the variables used in this REXX. *
000379 * *
000380 *------------------------------------------------------------*
000381 */
000382 init_variables:
000383 Drop trap_line. /* trapped from listcat */
000384 Drop out_line. /* output array */
000385 Drop state /* currently parsing this */
000386 Drop object_name /* cluster name */
000387 Drop data_name /* data name */
000388 Drop index_name /* index name */
000389 x = 0 /* current output line */
000390 indent = copies(' ',1)
000391 Return
000392
000393 /*------------------------------------------------------------*
000394 * *
000395 * Output any results and then exit this exec. *
000396 * *
000397 *------------------------------------------------------------*
000398 */
000399 output_results:
000400 Signal on syntax
000401 Call STEMVIEW 'BROWSE','out_line.',,,'VC "VSAM Clone"','ISRBROBF'
000402 Return
000403 Syntax: /* stemview function not available */
000404 Do i=1 To out_line.0
000405 Say out_line.i
000406 End
000407 Return
000408
****** **************************** Bottom of Data ****************************
|