/*------------------- REXX -----------------------------------* * * * This code does not do anything other than display the * * IDCAMS control statement needed to define a VSAM file. * * * * From ISPF 3.4, type VC next to a VSAM data set * * * * Written by Jim Connelley. No copyright. Ifyawanna, (If * * you want to) send your enhancements to jim@connelley.org * * * * There are bugs, such as handling multi-volume files, but * * that's where YOU come in. * * * * This code makes use of a handy command called STEMVIEW * * written by Gilbert Saint-flour available as source code * * as part of file # 183 at http://www.cbttape.org * * * *------------------------------------------------------------* */ Parse Arg data_set_name Address tso Call init_variables Call execute_listcat Call process_listcat indent = copies(' ',5) Call addkey ")" /* add closing paren */ out_line.0 = x /* set total linecount */ Call output_results Exit 0 /*------------------------------------------------------------* * * * process_listcat drives the processing of the LISTCAT * * output. * * * *------------------------------------------------------------* */ process_listcat: Do i = 1 To trap_line.0 Parse Var trap_line.i field1 the_rest Select When field1 = 'NONVSAM' Then Do out_line.0 = 1 /* set one line */ out_line.1 = "Not a VSAM data set:" data_set_name Call output_results Exit 0 End When field1 = 'CLUSTER' Then Do big_state = 'CLUSTER' Parse Var the_rest . object_name x = 1 out_line.x = indent "DEFINE" Call addkey "CLUSTER (" indent = copies(' ',5) Call addkey "NAME(" || object_name || ")" indent = copies(' ',10) Call addkey "INDEXED" /* KLUDGE default LINE 4 */ Call addkey "SHAREOPTION(2 1)" /* KLUDGE default LINE 5 */ End When field1 = 'DATA' Then Do big_state = 'DATA' Parse Var the_rest . data_name indent = copies(' ',5) Call addkey ")" indent = copies(' ',1) Call addkey "DATA(" indent = copies(' ',5) Call addkey "NAME(" || data_name || ")" indent = copies(' ',10) End When field1 = 'INDEX' Then Do big_state = 'INDEX' Parse Var the_rest . index_name indent = copies(' ',5) Call addkey ")" indent = copies(' ',1) Call addkey "INDEX(" indent = copies(' ',5) Call addkey "NAME(" || index_name || ")" indent = copies(' ',10) End When field1 = 'HISTORY' Then Do state = 'HISTORY' End When field1 = 'SMSDATA' Then Do state = 'SMSDATA' End When field1 = 'RLSDATA' Then Do state = 'RLSDATA' End When field1 = 'ASSOCIATIONS' Then Do state = 'ASSOCIATIONS' End When field1 = 'ATTRIBUTES' Then Do state = 'ATTRIBUTES' End When field1 = 'STATISTICS' Then Do state = 'STATISTICS' End When field1 = 'ALLOCATION' Then Do state = 'ALLOCATION' End When field1 = 'VOLUME' Then Do state = 'VOLUME' End Otherwise Select When state = 'SMSDATA' Then Do Call do_smsdata End When state = 'ATTRIBUTES' Then Do Call do_attributes End When state = 'ALLOCATION' Then Do Call do_allocation End When state = 'VOLUME' Then Do Call do_volume End Otherwise Nop End /* Select state */ End /* Select field1 */ End Return /*------------------------------------------------------------* * * * do_smsdata processes the keywords found under the SMSDATA * * section of output from listcat command. * * * *------------------------------------------------------------* */ do_smsdata: keyval = getkey('STORAGECLASS' trap_line.i) If keyval /= '' Then Call addkey "STORAGECLASS(" || keyval || ")" keyval = getkey('MANAGEMENTCLASS' trap_line.i) If keyval /= '' Then Call addkey "MANAGEMENTCLASS(" || keyval || ")" keyval = getkey('DATACLASS' trap_line.i) If keyval /= '' Then Call addkey "DATACLASS(" || keyval || ")" keyval = getkey('BWO----' trap_line.i) If keyval /= '' Then Call addkey "BWO(" || keyval || ")" Return /*------------------------------------------------------------* * * * do_volume processes the keywords and values found under * * under the volume section of the LISTCAT command. * * Currently, we are only interested in the VOLUME keyword. * * * *------------------------------------------------------------* */ do_volume: keyval = getkey('VOLSER' trap_line.i) If keyval /= '' Then Call addkey "VOLUMES(" || keyval || ")" Return /*------------------------------------------------------------* * * * do_allocation processes the keywords and values found * * under the allocation section of the LISTCAT command. * * * *------------------------------------------------------------* */ do_allocation: keyval = getkey('SPACE-TYPE' trap_line.i) If keyval /= '' Then space_type = keyval keyval = getkey('SPACE-PRI' trap_line.i) If keyval /= '' Then space_pri = keyval keyval = getkey('SPACE-SEC' trap_line.i) If keyval /= '' Then Call addkey space_type || "(" || space_pri keyval || ")" Return /*------------------------------------------------------------* * * * do_attributes process the non-default data under the * * ATTRIBUTES section of output from the LISTCAT command. * * * *------------------------------------------------------------* */ do_attributes: If big_state = 'DATA' Then Call do_attributes_data If big_state = 'INDEX' Then Call do_attributes_index keyval = getkey('BUFSPACE' trap_line.i) If keyval /= '' Then Call addkey "BUFFERSPACE(" || keyval || ")" keyval = getkey('EXCPEXIT' trap_line.i) If keyval /= '' Then Call addkey "EXCEPTIONEXIT(" || keyval || ")" keyval = getkey('CISIZE' trap_line.i) If keyval /= '' Then Call addkey "CONTROLINTERVALSIZE(" || keyval || ")" position = pos('SHROPTNS',trap_line.i) If position /= 0 Then Do position = position + length('SHROPTNS(') keyval = substr(trap_line.i,position,3) out_line.5 = indent "SHAREOPTIONS(" || keyval || ") -" End Call findkey "WRITECHECK" Call findkey "REUSE" If wordpos("NONINDEXED",trap_line.i) /= 0 Then out_line.4 = indent "NONINDEXED -" If wordpos("NUMBERED",trap_line.i) /= 0 Then out_line.4 = indent "NUMBERED -" If wordpos("LINEAR",trap_line.i) /= 0 Then out_line.4 = indent "LINEAR -" Return /*------------------------------------------------------------* * * * do_attributes_data processes those keywords that are * * only valid for the data portion of a cluster. . * * Currently these are KEYS(), RECORDSIZE(), erase and speed. * * * *------------------------------------------------------------* */ do_attributes_data: keyval = getkey('KEYLEN' trap_line.i) If keyval /= '' Then keylen = keyval keyval = getkey('RKP' trap_line.i) If keyval /= '' Then Call addkey "KEYS(" || keylen keyval || ")" keyval = getkey('AVGLRECL' trap_line.i) If keyval /= '' Then avglrecl = keyval keyval = getkey('MAXLRECL' trap_line.i) If keyval /= '' Then Call addkey "RECORDSIZE(" || avglrecl keyval || ")" Call findkey "ERASE" Call findkey "SPEED" Return /*------------------------------------------------------------* * * * do_attributes_index processes those keywords that are * * only valid for the index portion of a cluster. * * Currently these are REPLICATE and INBED. * * * *------------------------------------------------------------* */ do_attributes_index: Call findkey "REPLICATE" Call findkey "IMBED" Return /*------------------------------------------------------------* * * * getkey function scans a passed string for a * * specific keyword. If the keyword is found, getkey * * returns a value associated with the keyword. * * * * getkey is oriented to that ugly listcat output such as: * * STORAGECLASS -----SCPRIM * * example: * * getkey('STORAGECLASS','STORAGECLASS -----SCPRIM') * * * * getkey will return SCPRIM * * * *------------------------------------------------------------* */ getkey: procedure Parse Arg keyword str ret_str = '' position = pos(keyword,str) If position /= 0 Then Do len = length(keyword) position = position + len len = 24 - len ret_str = strip(strip(substr(str,position,len)),,'-') If ret_str = '(NULL)' Then ret_str = '' End Return ret_str /*------------------------------------------------------------* * * * findkey scans for a passed string and if it is found, * * adds the same string to the DEFINE statement. * * * *------------------------------------------------------------* */ findkey: Parse Arg keyword If wordpos(keyword,trap_line.i) /= 0 Then Call addkey keyword Return /*------------------------------------------------------------* * * * addkey procedure simply adds a passed value to the * * DEFINE statement that we are building. * * * * Put a check here for keywords such as recordsize(0 0) * * Return if found, because IDCAMS rejects such values * * as being 'out of range'. * * * *------------------------------------------------------------* */ addkey: procedure expose out_line. x indent Parse Arg keyword length_keyword = length(keyword) If length_keyword > 3 Then If substr(keyword,length_keyword-2,3) = '(0)' Then Return If length_keyword > 5 Then If substr(keyword,length_keyword-4,5) = '(0 0)' Then Return out_line.x = out_line.x "-" x = x + 1 out_line.x = indent keyword Return /*------------------------------------------------------------* * * * execute_listcat calls listcat command and handles return. * * * *------------------------------------------------------------* */ execute_listcat: data_set_name = strip(data_set_name,,"'") x = outtrap('trap_line.') "listcat entry('" || data_set_name || "') all" If RC /= 0 Then Do out_line.0 = 1 /* set one line */ out_line.1 = "listcat RC:" RC Call output_results Exit 0 End x = outtrap('off') If DATATYPE(trap_line.0) /= 'NUM' Then Do out_line.0 = 1 /* set one line */ out_line.1 = "listcat No output trapped" Call output_results Exit 0 End Return /*------------------------------------------------------------* * * * init_variables is coded promarily so we can add comments * * about the variables used in this REXX. * * * *------------------------------------------------------------* */ init_variables: Drop trap_line. /* trapped from listcat */ Drop out_line. /* output array */ Drop state /* currently parsing this */ Drop object_name /* cluster name */ Drop data_name /* data name */ Drop index_name /* index name */ x = 0 /* current output line */ indent = copies(' ',1) Return /*------------------------------------------------------------* * * * Output any results and then exit this exec. * * * *------------------------------------------------------------* */ output_results: Signal on syntax Call STEMVIEW 'BROWSE','out_line.',,,'VC "VSAM Clone"','ISRBROBF' Return Syntax: /* stemview function not available */ Do i=1 To out_line.0 Say out_line.i End Return