After completing this chapter, you will be able to describe the Rexx Tables.
The features of ISPF tables are as follows.
Analogous to arrays.
Can exist with or without a key.
Is stored in a PDS dataset.
Application library – ISPTLIB.
The table output library must be allocated to a ddname of ISPTABL. There are over 20 ISPF services that are relevant to tables.
The benefits of ISPF tables are as follows:
Ease of use.
Allows simple display of data.
Can be stored.
Keyed or Non-Keyed.
Optional variables on a per row basis.
The Restrictions in ISPF tables are as follows:
Processed in core.
Only process 1 row at a time.
Not a database.
The various commands used in ISPF tables are:
Let‘s look into the commands used in detail.
The command TBCREATE used to create a new ISPF table in virtual storage and opens it for processing.
Command Invocation format of TBCREATE is as follows,
ISPEXEC TBCREATE table-name [KEYS (key-name-list)] [NAMES (name-list)] [WRITE|NOWRITE]
in which name-list is the list of variables that forms the columns of the table, WRITE is the default option and indicates that the table is permanent and is to be saved either by TBSAVE or TBCLOSE, and NOWRITE specifies that the table is for temporary use only and it is to be deleted by either TBEND or TBCLOSE.
One or more variables can be defined as keys to a table. The table name can be 1 – 8 alphanumeric characters in length and must begin with an alphabet.
"TBCREATE FSTATUS KEYS (FCODE) NAMES (MESSAGE) WRITE " "TBCREATE TELBOOK KEYS (TELNO) NAMES (ADR1 ADR2)" "TBCREATE ADDRESS NAMES (NAME ADDR1 ADDR2 PIN) "
The command TBOPEN reads a permanent table from the table input file into virtual storage, and opens it for processing.
Command Invocation format of TBOPEN is as follows:
ISPEXEC TBOPEN table-name [WRITE|NOWRITE]
"ISPEXEC TBOPEN FSTATUS WRITE" and "ISPEXEC TBOPEN FSTATUS" are the same as WRITE is the default option
The command TBADD adds a new row of variables to the table. For tables without keys, the row is added after the current row. For tables with keys, the table is searched to ensure that the new row has a unique key.
Command Invocation format of TBADD is as follows,
ISPEXEC TBADD table-name [SAVE (name-list)] [ORDER]
In which, ORDER ensures no duplicate key condition.
"ISPEXEC TBADD TELBOOK ORDER AUTHOR"
Where TELBOOK is the table name and ORDER, AUTHOR are the fields in it.
The command TBSCAN searches a table for a row with values that match an argument list.
Command Invocation format of TBSCAN is as follows:
"ISPEXEC TBSCAN table-name [ARGLIST (name-list)]"
"ISPEXEC TBSCAN FSTATUS ARGLIST (FCODE)"
Where FSTATUS is the table name, FCODE is the argument it searches.
The command TBSKIP moves the current row pointer of a table forward by +1. All variables in the row, including keys and extension variables, if any, are stored into the corresponding variables as defined in the TBCREATE statement.
TBSKIP has many other parameters which are beyond the scope of this training.
Command Invocation format of TBSKIP is as follows:
"ISPEXEC TBSKIP table-name"
"ISPEXEC TBSKIP TABLE1"
The command TBSAVE writes the specified table from virtual storage to the table output library. The table output library must be allocated to the ddname ISPTABL. The table must be open in WRITE mode. TBSAVE does not delete the virtual storage of the table.
Command Invocation format of TBSAVE is as follows:
"ISPEXEC TBSAVE table-name NAME (alt-name)"
in which, 'alt-name' - the table will stored in the output library with the alternate name.
"ISPEXEC TSAVE TABLE1"
The command TBEND deletes the virtual storage copy of the specified table, making it unavailable for further processing. And the permanent copy is not changed.
Command Invocation format of TBEND is as follows:
"ISPEXEC TBEND table-name"
"ISPEXEC TBEND TABLE1"
The command TBCLOSE terminates processing of a specified table and deletes the virtual storage copy. If the table was opened in write mode, TBCLOSE copies the table from virtual storage to the table output library. If the table was opened in NOWRITE mode, TBCLOSE simply deletes the virtual storage copy.
Command Invocation format of TBCLOSE is as follows:
"ISPEXEC TBCLOSE table-name"
"ISPEXEC TBCLOSE FSTATUS"
Write a program to create an ISPF table to store the Name, Grade and status of students in a class. Take as input from the user the number of student records that must be inserted to the table.
Get the name and grade from the user. Based on the grade, the status "PASS" or "FAIL" must be decided. Once the records are inserted, scan the table and display the status of all the students.
/******************************* REXX *********************************/ ADDRESS ISPEXEC "LIBDEF ISPTABL DATASET ID ('RACFID.REXX.TABLES')" "TBERASE REXXTAB1" "TBCREATE REXXTAB1 KEYS (RNO) NAMES (NAME, GRADE, STATUS) WRITE" "TBCLOSE REXXTAB1" I = 0 SAY 'HOW MANY RECORDS NEED TO PROCESS' PULL I J = 1 DO J = 1 TO I BY 1 SAY'ENTER THE VALUES NAME GRADE (A OR B OR C OR D)' PULL INAME IGRADE IF IGRADE = 'D' THEN ISTATUS = 'FAIL' ELSE IF IGRADE = 'A'| IGRADE = 'B' | IGRADE = 'C' THEN ISTATUS = 'PASS' ELSE ISTATUS ='INVALID GRADE' * RECORD VALUES ADD TO TABLE */ RNO = J NAME = STRIP (INAME) GRADE = STRIP (IGRADE) STATUS = STRIP (ISTATUS) "TBOPEN REXXTAB1" "TBADD REXXTAB1" IF RC /= 0 THEN SAY 'THE RECORD 'RNO'ADD TO TABLE FAILED' "TBCLOSE REXXTAB1" END DO J = 1 TO I BY 1 RNO = J /* SCANNING FOR RECORD VALUES FROM TABLE */ "TBOPEN REXXTAB1" "TBSCAN REXXTAB1 ARGLIST (RNO)" "TBCLOSE REXXTAB1" SAY'STATUS OF 'NAME' IS:'STATUS END EXIT
ISPF tables provide various services to perform table related operations. In the code, TBERASE command deletes the table (if it exists) and TBCREATE creates a new table with the field names specified.
TBOPEN command opens the table, TBADD adds rows to it and TBCLOSE closes the table.
For each of the table operations return code may be evaluated. Successful operation is denoted by RC of 0 while a non-zero return code suggests failure.
Provide proper comments as needed.
Indent the code, since REXX instructions can begin in any column.
ISPF tables, although not a database, can be used to store data and is beneficial because of its ease of use and simple display of data.
Various Table services are available for creating applications that use ISPF tables:
Services that affect table rows like TBADD, TBDELETE, TBGET, TBMOD, TBSCAN and so on
Services that affect the entire table like TBCREATE, TBOPEN, TBCLOSE, TBSORT and so on
Which command is used to search a row in a table?
Which is the default option while creating a table?
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!