home about us   contact us
 
   







 


Chicago-Soft
ATTN: TSO Times
One Maple Street
Hanover, NH 03755
(603) 643-4002
information
@tsotimes.com

 

An ISPF Dialog for Viewing an ISPF Table

by Doug Bolin

If you've developed ISPF dialogs that manipulate data in ISPF tables, you've probably wanted TBBROWSE or TBEDIT table services. Knowing what's happening to your Table data can vastly improve development turnaround time. There is a Dialog Test (PDF option 7.4) facility that supports tables, but it's difficult to manage, and it only displays one row at a time. Tailored panels and the TBDISPL service help, but those take time to prepare; the more variables on a row, the longer they can take. The dialog included here is a general-purpose ISPF Table Viewer, written in REXX. It should be able to display most ISPF Tables in a spreadsheet (row and column) format, with scrolling in all directions. It is built in two pieces: TBV is a start-up 'shell', which calls TBVIEW, the viewer itself.

Here's how the utility operates: TBV verifies and LIBDEFs an input table library (if one is specified), and/or TBOPENs a table located on disk--the viewer (TBVIEW) works only on an available table. TBVIEW uses TBQUERY to return the table's keys and names, which become column headings. The table is then scanned to determine the maximum-width value to be displayed in each column.

Once the maximum widths are known, each column is formatted and placed sequentially onto screen-wide display areas. Additional screen widths are allocated as required. When all columns are placed, the table is displayed using the TBDISPL service. Use of END/RETURN (or a jump instruction) terminates the display and the utility. The shell REXX, TBV, can accept two arguments: (1) table name, and (2) input table library dataset name. If neither is provided, a panel is displayed on which they may be entered (table name is required).

Features of the dialog include:
* Works with Disk-based or temporary (TBCREATE NOWRITE) tables, performs LIBDEFs and TBOPEN/TBEND only as required.
* Non-destructive--no updates made to table (TBTOP, TBSKIP only).
* Key values are highlighted, Name Values are lowlighted.
* Column data wider than ZSCREENW is trimmed.
* Command line or panel invocation.
* May be embedded in other Dialogs for debugging/application critical purposes.
* Entire product requires only two panels and two REXX processes, and is extendable.

Limitations:
* Does not recognize extension variables (such as in Profile or Command tables).
* Determination of column data widths, in larger tables, takes some time.
* Lacks browse functions, such as Find.

Download this exec in text format (ISPFTBL.TXT)

 SOURCE
Section:
TBV - ISPF table viewer, Startup Shell: REXX EXEC

       /* TBV - Invokes ISPF Table View Utility ( REXX ) */
 Trace Off
 Parse Arg tblname tbllib
 Address ISPEXEC "LIBDEF ISPPLIB DATASET ID('userid.ISPF.PANELS')"
 /* If arguments are not passed, request them via panel TBVENT */
 If tblname = ''
 Then do
	Address ISPEXEC "DISPLAY PANEL(TBVENT)"
	If rc > 0
	Then Call Ending
	end
If tbllib = ''    /* Optional - Test; if ok, then LIBDEF it */
 Then do
	dsn = SYSDSN(tbllib)
	If dsn = 'OK'
	Then do
		Zerrsm = "Table Lib unavailable"
		Zerrlm = "Dataset" tbllib "not OK, Sysdsn:" dsn
		Zerralrm = "YES"
		Zerrhm = "*"
		Address ISPEXEC "SETMSG MSG(ISRZ002)"
		Call Ending
		end
	Address ISPEXEC "LIBDEF ISPTLIB DATASET ID("tbllib")"
	end
 Address ISPEXEC "TBSTATS" tblname "STATUS1("sta1") STATUS2("sta2")"
 opened_it = 0
 If sta1 = 1 & sta2 = 1 /* on input lib(sta1=1) but not open(sta2=1)*/
 Then do
	Address ISPEXEC "TBOPEN" tblname "NOWRITE"
	opened_it = 1
	end
If ( sta1 > 1 & sta2 = 1 )         /* otherwise unavailable */
 Then do
	Zerrsm = "Table not found"
	Zerrlm = "Table could not be opened? Status:" sta1 sta2
	Zerralrm = "YES"
	Zerrhm = "*"
	Address ISPEXEC "SETMSG MSG(ISRZ002)"
	Call Ending
	end
                                  /* call the table viewer */
 Address ISPEXEC ,
	"SELECT CMD(EX 'userid.ISPF.CLIST(TBVIEW)' '"tblname"' EXEC)"
 If opened_it = 1
 Then Address ISPEXEC "TBEND" tblname
 If tbllib = ''
 Then Address ISPEXEC "LIBDEF ISPTLIB"
 Ending:
 Address ISPEXEC "LIBDEF ISPPLIB"
 Exit
 
--------------------------------------------------------------------------------------------- -------
TBVIEW - ISPF table viewer, Core: REXX EXEC
--------------------------------------------------------------------------------------------- -------
                      /* Generic ISPF table viewer ( REXX ) */
	Trace Off
	tblname = arg(1)
	Address ISPEXEC "CONTROL ERRORS RETURN"
         /* Phase 1 - query the table, capture variable names */
	Address ISPEXEC "TBQUERY" tblname "KEYS(KEYS) NAMES(NAMES)",
	"KEYNUM(KEYNUM) NAMENUM(NAMENUM)"
	keys  = strip(keys,l,'(')  ; keys  = strip(keys,t,')')
	names = strip(names,l,'(') ; names = strip(names,t,')')
	varnum = keynum + namenum
	allvars = keys names	  /* chain keys and names together */
	do col = 1 to varnum /* arrays of column headings, widths*/
	name.col = word(allvars,col)     /* name of the variable */
	hdw.col  = length(name.col)             /* width of name */
	dwid.col = 0	                 /* max width of data found */
	end
     /* Phase 2 - Review the table for data displayed widths -- 
        currently fixed to max out at zscreenw-1 (usually 79) */
	Address ISPEXEC "VGET ZSCREENW"
	maxwid = zscreenw - 1     /* need one for attribute byte */
	Address ISPEXEC "TBTOP" tblname
	tbrc = 0
	do while tbrc = 0
	Address ISPEXEC "TBSKIP" tblname
	tbrc = rc
	if tbrc = 0
	then do col = 1 to varnum
	if length(value(name.col)) > dwid.col
	then dwid.col = length(value(name.col))
	end
	end
     /* Phase 3 - Set reserved width, headings for each
                     column, and use to build screen widths. */
	maxscr = 1
              /* total screens required to display all columns */
	modhdrs = '' ; modvars = '' ; mdzvars = ''
	cols_this_screen = 0          /* what's been used so far */
	do col = 1 to varnum
	if dwid.col = 0
	then dwid.col = 1
	if dwid.col > maxwid
	then dwid.col = maxwid
	grtrwid  = max(hdw.col,dwid.col)
	rsvd.col = 1 + grtrwid      /* one space between columns */
	hdng.col = ' ' || center(name.col,grtrwid,'-')
	if cols_this_screen + rsvd.col > zscreenw
	then do	   /* starting a new screen for this column */
	modhdr.maxscr = modhdrs     /* save prior screen formats */
	modvar.maxscr = modvars
	mdzvar.maxscr = mdzvars
	modhdrs = '' ; modvars = '' ; mdzvars = ''
	maxscr = maxscr + 1	             /* begin a new screen */
	cols_this_screen = 0
	end
	modhdrs = modhdrs || hdng.col
	if col <= keynum	       /* these are high intensity */
	then marker = left('@z',dwid.col+1)
	else marker = left('\z',dwid.col+1)
	modvars = modvars || center(marker, rsvd.col)
	mdzvars = mdzvars name.col
	cols_this_screen = cols_this_screen + rsvd.col
	end
	modhdr.maxscr = modhdrs   /* save the last screen format */
	modvar.maxscr = modvars
	mdzvar.maxscr = mdzvars
      /* Phase 4 - Display the table using prepared screens. Saves and
           sets 4 pkfeys to allow left and right scrolling effect. */
	Address ISPEXEC "VGET (ZPF10 ZPF11 ZPF22 ZPF23) PROFILE"
	spf10 = zpf10 ; spf11 = zpf11 ; spf22 = zpf22 ; spf23 = zpf23
	zpf10 = 'TLEFT' ; zpf11 = 'TRIGHT'
	zpf22 = 'TLEFT' ; zpf23 = 'TRIGHT'
	Address ISPEXEC "VPUT (ZPF10 ZPF11 ZPF22 ZPF23) PROFILE"
	curscrn = 1
	crp = 1
	call load_screen_vars
	viewrc = 0
	do while viewrc < 8
	Address ISPEXEC "TBTOP" tblname
	Address ISPEXEC "TBSKIP" tblname "NUMBER("crp")"
	Address ISPEXEC "TBDISPL" tblname "PANEL(TBVIEW)"
	viewrc = rc
	if viewrc < 8
	then do
	crp = ztdtop
	if zcmd = 'TRIGHT'
	then do
	curscrn = curscrn + 1
	if curscrn > maxscr
	then curscrn = 1
	call load_screen_vars
	end
	else if zcmd = 'TLEFT'
	then do
	curscrn = curscrn - 1
	if curscrn = 0
	then curscrn = maxscr
	call load_screen_vars
	end
	end
	end
	zpf10 = spf10 ; zpf11 = spf11 ; zpf22 = spf22 ; zpf23 = spf23
	Address ISPEXEC "VPUT (ZPF10 ZPF11 ZPF22 ZPF23) PROFILE"
	Ending:
	Return
 load_screen_vars : 
                 /* moves current screen formats to actives */
	modhdrs = modhdr.curscrn
	modvars = modvar.curscrn
	mdzvars = mdzvar.curscrn
	Return
------------------------------------------------------------------------------
TBVENT - ISPF table viewer, Entry Panel: ISPF PANEL
------------------------------------------------------------------------------
)Attr
  type(text) intens(low) skip(on)
)body width(&zscreenw) expand(//)
+/-/%ISPF Table Viewer+/-/
%Command ==>_ZCMD
+
+	Enter%ISPF Table+to view:
	%==>_tblname 
+
+	Enter the%ISPF Table Library+in which the Table resides (if not current):
	%==>_tblli b	
+
+Press%Enter+to begin Table View
+Press%End Key+to quit
)init
)proc
 ver (&tblname,nb,name)
 ver (&tbllib,dsname)
)end
----------------------------------------------------------------------------
TBVIEW - ISPF table viewer, Table Display Panel: ISPF PANEL
------------------------------------------------------------------------------
)attr default(%+_)
  @ type(output) intens(high) color(red )	 /* key values */
  \type(output) intens(high) color(green)    /* name values */
  ~ type(output) intens(high) just(right) caps(off)
                                            /* screen x of n */
)body width(&zscreenw) expand(//)
+ISPF Table :\TBLNAME +/-/
%Command ==>_ZCM D	~scrnum
+
&modhdrs
)model
&modvars
)init
 .zvars	= '&mdzvars'
 &pt1	= 'Screen'
 &pt2	= 'of'
 &scrnum  = '&pt1 &curscrn &pt2 &maxscr'
 &ztdmark = '---------- Bottom of Table ----------'
)end

Doug Bolin, Senior Programmer/Analyst, CS First Boston, New York, New York.




The TSO Times is back by popular demand!
Register now for your FREE subscription









 

Chicago-Soft, LTD
ISPF Tools & Toys
MVS Help Board
Lionel Dyck's Tools
IBM ISPF Page
Tom Brennan's Vista tn3270 Page
Mark Zelden's MVS Utilities


 


 

home · current articles · archives · forums ·
· subscribe · about us · contact us · links