/* REXX ALIST Display the user's current allocations Use '(routine name) ?' for HELP-text. |**-***-***-***-***-***-***-***-***-***-***-***-***-***-***-***-**| | | | WARNING: EMBEDDED COMPONENTS. | | See text following TOOLKIT_INIT | | | |**-***-***-***-***-***-***-***-***-***-***-***-***-***-***-***-**| Written by Frank Clarke, rexxhead@yahoo.com Impact Analysis . SYSEXEC LA . SYSEXEC TRAPOUT Modification History 20210510 fxc Use LA to get dsnames 20230203 fxc call from READY 20230506 fxc adjust HELP; 20230606 fxc use MEMLIST 20230613 fxc add DEL to DEIMBED ALLOC 20230806 fxc chg SYSPROC to SYSEXEC in Impact Analysis; 20230911 fxc use ZUP/ZCONT in HELP panels; 20231030 fxc can't LMINIT for a member of a PDS; 20231116 fxc add HELP prompt on panel; 20240305 fxc align panel names; 20240308 fxc chg dollar-sign to @ everywhere; 20240404 fxc changed tutorial to scrollable area; 20240414 fxc DUMP_QUEUE quiet; 20250219 fxc add ZTDMARK at bottom of scroll; 20250313 fxc do NOT re-initialize tk_globalvars; 20250327 fxc missing comma; 20250515 fxc fix DEIMBED; 20250916 fxc new BACKEND; new SPACEOUT; 20250925 fxc chg setting of sw. to sw.0; */ arg argline address TSO /* default address */ arg parms "((" opts signal on syntax signal on novalue call TOOLKIT_INIT /* conventional start-up -*/ rc = Trace( "O" ); rc = Trace( tv ) info = parms /* to enable parsing */ if sw.0inispf = "0" then do arg line line = line "(( RESTARTED" /* tell the next invocation */ address TSO "ISPSTART CMD( "exec_name line" )" /* Invoke ISPF if nec. */ exit 2 /* ...and restart it */ end rc = Trace( "O" ) ; rc = Trace( tv ) address ISPEXEC "CONTROL ERRORS RETURN" call A_INIT /* -*/ call B_GET_ALLOCATIONS /* -*/ call C_LOAD_TABLE /* -*/ call D_TABLE_OPS /* -*/ call E_REDO_ALLOC /* -*/ if \sw.0nested then call DUMP_QUEUE 'quiet' /* -*/ if sw.0restart then do /* at end of mainline */ rc = OutTrap( "ll." ) exit 4 end exit /*@ ALIST */ /* Initialization . ----------------------------------------------------------------- */ A_INIT: /*@ */ if branch then call BRANCH address TSO parse value "0 ISR00000 YES" with, got_one zerrhm zerralrm zerrsm zerrlm ZTDMARK = "====== Bottom of data ======" @tn@ = "T"Right( Time( "S" ),5,0 ) /* T32855 maybe #*/ if monitor then say, "Table in use is" @tn@ parse value "?" with, ddname dsnames. disp. , ddlist , dds_to_realloc ds_stack. sw.0redo_alloc = "0" save_rc = 0 return /*@ A_INIT */ /* Find datasets to display. . ----------------------------------------------------------------- */ B_GET_ALLOCATIONS: /*@ */ if branch then call BRANCH address TSO tgt_list = "" do ii = 1 to Words( parms ) /* for every file name */ this_tgt = Word( parms,ii ) if this_tgt = "ISPF" then, /* expand ISPF */ tgt_list = tgt_list "ISPPLIB ISPMLIB ISPSLIB ISPTLIB", "ISPTABL ISPLLIB ISPPROF" else, if this_tgt = "CMDS" |, /* expand CMDS */ this_tgt = "COMMANDS" then, call BA_Q_ALTLIB /* -*/ else, /* just add to the list */ tgt_list = tgt_list this_tgt end /* ii */ rc = Trace( "O" ); rc = Trace( tv ) "NEWSTACK" "LA" tgt_list "((STACK LIST" do queued() /* each DDName */ parse pull ddname ":" dsnames dsnames.ddname = dsnames ddlist = ddlist ddname disp.ddname = "KEEP" end /* queued */ "DELSTACK" if monitor then say, "Processing DDNames:" ddlist return /*@ B_GET_ALLOCATIONS */ /* Any ALTLIBs? Include those, too. . ----------------------------------------------------------------- */ BA_Q_ALTLIB: /*@ */ if branch then call BRANCH address TSO @x = Outtrap( "alt." ) /* set up outtrap */ "ALTLIB DISPLAY" /* get ddname-list */ @x = Outtrap( "OFF" ) /* release trap */ do bax = 1 to alt.0 parse var alt.bax "DDNAME=" baxddn . tgt_list = tgt_list baxddn end /* bax */ if monitor then say, "Processing DDNames:" tgt_list return /*@ BA_Q_ALTLIB */ /* Build table of DDNs and DSNs . ----------------------------------------------------------------- */ C_LOAD_TABLE: /*@ */ if branch then call BRANCH address ISPEXEC if tgt_list = "" then tgt_list = ddlist "TBCREATE " @tn@ " NAMES( DDNAME DSNAME DISP SEQ ) NOWRITE" do Words( tgt_list ) /* every DDName */ parse var tgt_list ddname tgt_list ds_stack.ddname = dsnames.ddname disp = disp.ddname seq = 0 do Words( dsnames.ddname ) parse var dsnames.ddname dsname dsnames.ddname seq = seq + 1 "TBADD" @tn@ /* add to table #*/ got_one = "1" end /* dsnames */ end /* Words( tgt_list ) */ return /*@ C_LOAD_TABLE */ /* Display the table. . ----------------------------------------------------------------- */ D_TABLE_OPS: /*@ */ if branch then call BRANCH address ISPEXEC if got_one then do call DEIMBED /* expose the panel -*/ @ddn = @ddn.PLIB "LIBDEF ISPPLIB LIBRARY ID( "@ddn" ) STACK" "TBSORT" @tn@ "FIELDS( DDNAME,C,A SEQ,N,A )" "CONTROL DISPLAY SAVE" /* In case of re-invocation */ do forever "TBDISPL" @tn@ "PANEL( FCALLOC ) CURSOR( ACTION )", "AUTOSEL( NO )" if rc > 4 then leave do ztdsels curact = Translate( action ) "CONTROL DISPLAY SAVE" select when Pos( curact,"EVB" ) > 0 then do parse var dsname mlname "(" "LMINIT DATASET( '"mlname"' ) DATAID( MEMLV )" "MEMLIST DATAID( "memlv" ) FIELD( 9 )", "DEFAULT( " curact " )" "LMFREE DATAID( "memlv" )" end /* EVB */ when curact = "D" then do /* DUP */ address TSO "DUP '"dsname"' ID" save_rc = rc if rc <> 0 then do ZERRSM = "RC ="rc ZERRLM = "DUP ended abnormally" end end /* DUP */ when curact = "F" then do /* Free */ sw.0redo_alloc = "1" if WordPos( ddname,dds_to_realloc ) = 0 then, /* new */ dds_to_realloc = dds_to_realloc ddname dsid = WordPos( dsname,ds_stack.ddname ) /* known ? */ if dsid > 0 then, ds_stack.ddname = DelWord( ds_stack.ddname,dsid,1 ) end /* Free */ when curact = "X" then do /* UnDisplay */ "TBDELETE" @tn@ /* drop this row */ end /* UnDisplay */ otherwise nop end /* Select */ "CONTROL DISPLAY RESTORE" if save_rc <> 0 then, "SETMSG MSG( ISRZ002 )" save_rc = 0 if ztdsels = 1 then, /* never do the last one */ ztdsels = 0 else "TBDISPL" @tn@ /* next row #*/ end /* ztdsels */ action = "" /* clear for re-display */ end /* forever */ "CONTROL DISPLAY RESTORE" /* In case of re-invocation */ "LIBDEF ISPPLIB" "TBCLOSE" @tn@ address TSO "FREE FI( "@ddn" )" end /* got_one */ else do "TBEND" @tn@ /* #*/ ZERRSM = "No datasets" /* short message */ ZERRLM = "No datasets were allocated as specified/implied." "SETMSG MSG( ISRZ002 )" end return /*@ D_TABLE_OPS */ /* . ----------------------------------------------------------------- */ E_REDO_ALLOC: /*@ */ if branch then call BRANCH address TSO /* ready for some TSO work */ if sw.0redo_alloc then do do fidx = 1 to Words( dds_to_realloc )/* for each DDName */ ddname = Word( dds_to_realloc,fidx ) /* grab it */ alloc_list = "" /* initialize */ if Words( ds_stack.ddname ) > 0 then, do didx = 1 to Words( ds_stack.ddname ) /* for each DSName */ alloc_list = alloc_list "'"Word( ds_stack.ddname,didx )"'" end if alloc_list <> "" then, /* re-ALLOC */ "ALLOC FI( "ddname" ) DA( "alloc_list" ) SHR REU" else "FREE FI( "ddname" )" end /* fidx */ end /* sw.0redo_alloc */ return /*@ E_REDO_ALLOC */ /* . ----------------------------------------------------------------- */ LOCAL_PREINIT: /*@ customize opts */ address TSO sw.0restart = SWITCH( "RESTARTED" ) /* in LOCAL_PREINIT */ return /*@ LOCAL_PREINIT */ /* subroutines below LOCAL_PREINIT are not selected by SHOWFLOW */ /* Parse out the embedded components at the back of the source code. . ----------------------------------------------------------------- */ DEIMBED: Procedure expose, /*@ */ (tk_globalvars) ddnlist @ddn. daid. address TSO dlm = '5d5d5d'x /* three close-parens */ fb80po.0 = "NEW DELETE REU UNIT( SYSDA ) SPACE( 1 5 ) DIR( 40 )", "TRACKS RECFM( F B ) LRECL( 80 ) BLKSIZE( 0 )" fb80po.1 = "SHR REU" parse value "" with ddnlist @ddn. daid. lastln = sourceline() currln = lastln /* */ if Left( sourceline( currln ),2 ) <> "*/" then return currln = currln - 1 /* previous line */ "NEWSTACK" address ISPEXEC do while Left( sourceline( currln ),2 ) <> "/*" text = sourceline( currln ) /* save with a short name ! */ if Left( text,3 ) = dlm then do /* package the queue */ parse var text . ddn mbr . /* PLIB PANL001 maybe */ if length( ddn ) > 4 then do /* data, not ISPF */ call DESPOOL /* -*/ currln = currln - 1 /* previous line */ iterate end if Pos( ddn,ddnlist ) = 0 then do /* doesn't exist */ ddnlist = ddnlist ddn /* keep track */ @ddn = ddn || Random( 999 ) /* PLIB322 maybe */ @ddn.ddn = @ddn /* @ddn.PLIB = PLIB322 */ address TSO "ALLOC FI( "@ddn" )" fb80po.0 "LMINIT DATAID( DAID ) DDNAME( "@ddn" )" daid.ddn = daid end daid = daid.ddn "LMOPEN DATAID( "daid" ) OPTION( OUTPUT )" do queued() parse pull line "LMPUT DATAID( "daid" ) MODE( INVAR ) DATALOC( LINE )", "DATALEN( 80 )" end "LMMADD DATAID( "daid" ) MEMBER( "mbr" )" "LMCLOSE DATAID( "daid" )" end /* package the queue */ else push text /* onto the top of the stack */ currln = currln - 1 /* previous line */ end /* while */ address TSO "DELSTACK" return /* Subroutine of DEIMBED for non-ISPF data. Given : the stack, ddn, and mbr . ----------------------------------------------------------------- */ DESPOOL: /*@ */ if branch then call BRANCH address TSO if WordPos( ddn,ddnlist ) = 0 then, ddnlist = Space( ddnlist ddn,1 ) if Sysdsn( ddn".DATA" ) <> "OK" then, "ALLOC FI( "ddn" ) DA( "ddn".DATA )" fb80po.0 "ALLOC FI( "ddn" ) DA( "ddn".DATA( "mbr" ) ) SHR REU" "EXECIO" queued() "DISKW" ddn "(FINIS" "DELSTACK" "NEWSTACK" /* re-establish */ return /*@ DESPOOL */ return /*@ DEIMBED */ /* . ----------------------------------------------------------------- */ HELP: /*@ */ address TSO;"CLEAR" if helpmsg <> "" then say helpmsg ex_nam = Left(exec_name,8) /* predictable size */ say " " say " "ex_nam" displays a scrollable list of allocated datasets. The " say " list may be limited to specific DDNames or specific sets " say " of DDNames. It may be invoked from READY-mode. " say " " say " Syntax: "ex_nam" ddnlist " say " CMDS or COMMANDS " say " ISPF " say " " say " ddnlist is a blank-delimited list of filenames to be " say " displayed. if ddnlist is empty, ALL allocated " say " DDNames are processed. " say " " say " CMDS is equivalent to 'SYSPROC SYSEXEC' " say " " say " ISPF is equivalent to 'ISPPLIB ISPMLIB ISPSLIB " say " ISPTLIB ISPLLIB ISPPROF ISPTABL' " "NEWSTACK"; pull ; "CLEAR" ; "DELSTACK" say " Debugging tools provided include: " say " " say " MONITOR: displays key information throughout processing. " say " " say " BRANCH: show all paragraph entries. " say " " say " TRACE tv: will use value following TRACE to place the " say " execution in 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" (( MONITOR TRACE ?R " if Sysvar( "SYSISPF" ) = "ACTIVE" then, 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 ) /* 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 arg mode . "QSTACK" /* how many stacks? */ stk2dump = rc - tk_init_stacks /* remaining stacks */ if stk2dump = 0 & queued() = 0 then return if mode <> "QUIET" then, say "Total Stacks" rc , /* rc = #of stacks */ " Begin Stacks" tk_init_stacks , /* Stacks present at start */ " Excess Stacks to dump" stk2dump do dd = rc to tk_init_stacks by -1 /* empty each one. */ if mode <> "QUIET" then, say "Processing Stack #" dd " Total Lines:" queued() do queued();parse pull line;say line;end /* pump to the screen */ "DELSTACK" /* remove stack */ end /* dd = 1 to rc */ return /*@ DUMP_QUEUE */ /* Handle CLIST-form keywords added 20020513 . ----------------------------------------------------------------- */ CLKWD: Procedure expose info /*@ hide all except info */ arg kw kw = kw"(" /* form is 'KEY(DATA)' */ kw_pos = Pos( kw,info ) /* find where it is, maybe */ if kw_pos = 0 then return "" /* send back a null, not found*/ rtpt = Pos( '5d40'x,info" ",kw_pos ) /* locate end-paren */ slug = Substr( info,kw_pos,rtpt-kw_pos+1 ) /* isolate */ info = Delstr( info,kw_pos,rtpt-kw_pos+1 ) /* excise */ parse var slug (kw) slug /* drop kw */ slug = Reverse( Substr( Reverse( Strip( slug ) ),2 ) ) return slug /*@CLKWD */ /* Handle multi-word keys 20020513 . ----------------------------------------------------------------- */ 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+Words( kw ) ) /* 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" )", info if wordpos( dlm,back ) = 0 then /* search for ending delimiter*/ helpmsg = helpmsg, "No matching second delimiter( "dlm" ) with KEYPHRS( "kp" )", info 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 Strip( sourceline( ssii ),'T' ) 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','5d'x ) /* 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 */ sw.0nested = sysvar( "SYSNEST" ) = "YES" sw.0batch = sysvar( "SYSENV" ) = "BACK" sw.0inispf = sysvar( "SYSISPF" ) = "ACTIVE" parse value KEYWD( "TRACE" ) "N" with tv . 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 . 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 */ /* ))) PLIB FCALLOC .. )ATTR % TYPE( TEXT ) INTENS( HIGH ) SKIP( ON ) + TYPE( TEXT ) INTENS( LOW ) SKIP( ON ) _ TYPE( INPUT ) INTENS( HIGH ) ! TYPE( OUTPUT ) INTENS( HIGH ) SKIP( ON ) )BODY EXPAND(||) %|-| Current Allocations |-| %COMMAND ===>_ZCMD %SCROLL ===>_AMT + + +Table:!@tn@ + DDName DSName %PF1 for HELP )MODEL _Z+ !DDNAME + !DSNAME + )INIT .ZVARS = '(ACTION)' .HELP = FCALLOCH )REINIT IF (&MSG = ' ') &ACTION = ' ' REFRESH (&ACTION) )END ))) PLIB FCALLOCH .. )ATTR % TYPE( TEXT ) INTENS( HIGH ) SKIP( ON ) + TYPE( TEXT ) INTENS( LOW ) SKIP( ON ) _ TYPE( INPUT ) INTENS( HIGH ) ! TYPE( OUTPUT ) INTENS( HIGH ) SKIP( ON ) @ TYPE( OUTPUT ) INTENS( LOW ) SKIP( ON ) } AREA( SCRL ) EXTEND( ON ) )BODY EXPAND(||) %TUTORIAL |-| Current Allocations |-| TUTORIAL %Next Selection ===>_ZCMD + }hlptxt } )AREA HLPTXT + + Panel FCALLOC shows the current allocations for the DDNames you specified + (or ALL DDNames). + + For each shown dataset you may select among several actions: + + %B+-%BROWSE +Browse the selected dataset. + + %E+-%EDIT +Edit the selected dataset. + + %V+-%VIEW +View the selected dataset. + + %D+-%DUP +You may make a copy (either filled or empty) of the + selected dataset. Subroutine DUP will be called to + perform this function. + + %F+-%FREE +This is effective only for DDNames which are not under + the control of ISPF since those files are necessarily + OPEN while ISPF is active. + )PROC &ZUP = FCALLOCH &ZCONT = FCALLOCH )END */