Uploaded by UNIVERSO MAINFRAME

342670920-ISPF-Tables

advertisement
Introduction to ISPF Tables
Table Basics
• An ISPF table is a simple database.
• Each row in the table is like a record in a standard file, and each column
is like a field.
• Each row within a table can be uniquely identified by its row number. At
any given time, one of the rows is the current row. ISPF keeps track of the
current row for a table by maintaining a current row pointer, or CRP.
Types of Variables
• Keys
• Names
Command
TBADD
Function
Add a row to a table
TBBOTTOM Moves to the bottom of the table
TBCLOSE
TBCREATE
Saves and closes the table
Creates and opens the table
TBDELETE
Deletes an existing row
TBDISPL
Displays table rows using a model
panel
Command
Function
TBGET
Retrieves a row from a table
TBMOD
Updates an existing row or adds a new
TBOPEN
Opens an existing permanent table
TBPUT
Updates an existing row
TBSARG
TBDISPLY
Sets up a search argument for
TBSCAN
Locates a row based on its contents
row
TBSCAN or
Command
Function
TBSKIP
Moves forward or backward a specified
no.of rows
TBSORT
rows to be placed
Sorts the rows of an existing table and
causes all new
according to the specified sequence
TBTOP
Moves to the top of the table
Types of Tables
• Permanent Table
• Temporary Table
Allocating Table Libraries
• Only for Permanent Tables
• Using LIBDEF command
• DDNAME ISPTLIB - CREATE, READ,
OPEN
• DDNAME ISPTABL - WRITE
Example
"ISPEXEC LIBDEF ISPTLIB
DATASET ID(USER.TABLES)"
"ISPEXEC LIBDEF ISPTABL
DATASET ID(USER.TABLES)"
Table Dataset Attributes
• Should be a PDS
• Record length = 80
• Block Size
= 3120 bytes
TBCREATE command
"ISPEXEC TBCREATE table-name
[KEYS(key-name-list)]
[NAMES(name-list)]
[WRITE/NOWRITE]
[ REPLACE ]"
Examples
Example 1
"ISPEXEC TBCREATE TDOCS KEYS(DOCID)
NAMES(TITLE)"
Example 2
"ISPEXEC TBCREATE TDOCS NAMES(DOCID
TITLE)"
Example 3
"ISPEXEC TBCREATE TDOCS NAMES(DEPT
EMPNO QTY) NOWRITE"
TBSORT Command
Syntax:
"ISPEXEC TBSORT table-name
FIELDS(variable-1,C/N,A/D [,variable-2…])"
Note:TBSORT needs to be specified only once
for each table. The sort specification is
maintained along with the table, and any
additions to the table are made in the correct
sequence.
Examples
Example 1
"ISPEXEC TBSORT TDOCS
FIELDS(DOCID,C,A)"
Example 2
"ISPEXEC TBSORT TDOCS
FIELDS(TITLE,C,A)"
Example 3
"ISPEXEC TBSORT TUSERS
FIELDS(LNAME,C,A,FNAME,C,A)"
TBOPEN Command
Syntax:
"ISPEXEC TBOPEN table-name
[WRITE/NOWRITE]"
- table doesn’t exist,
wrong table name,
library problem
RC12 - table in use
RC16 - no ISPTLIB allocated.
RC20 - severe error.
RC8
TBADD Command
Syntax:
"ISPEXEC TBADD table-name [ORDER]"
RC8
duplicate row exists if KEY
columns exist.
TBGET Command
Syntax:
"ISPEXEC TBGET table-name"
RC8
No rows matching key value (for
table with
key fields)
Pointer was positioned before the
first row ( for table without key)
TBPUT and TBMOD Commands
Syntax:
"ISPEXEC TBPUT table-name"
"ISPEXEC TBMOD table-name"
RC8
Row to be updated didn’t
and a new row was
created.
exist
TBDELETE Command
Syntax:
"ISPEXEC TBDELETE table-name"
RC8-
row didn’t exist
TBSKIP, TBTOP, and TBBOTTOM commands
Syntax:
"ISPEXEC TBSKIP table-name
[NUMBER(number)]"
RC8
moved beyond the range
table
"ISPEXEC TBTOP table-name"
"ISPEXEC TBBOTTOM table-name"
of the
Examples
Example 1
"ISPEXEC TBSKIP TDOCS NUMBER(1)"
Example 2
"ISPEXEC TBSKIP TDOCS NUMBER(-1)"
Default Number is 1.
TBSCAN and TBSARG commands
Syntax:
"ISPEXEC TBSCAN table-name
ARGLIST(var1 var2 …)
CONDLIST(cond1 cond2 ...)"
Example
"ISPEXEC TBSCAN TDOCS
ARGLIST(TITLE)"
RC8 -
Row not found
CONDLIST
EQ
NE
LE
LT
GE
GT
Equal
Not Equal
Less than or Equal
Less than
Greater than or Equal
Greater than
Examples
"ISPEXEC TBSCAN TORDER
ARGLIST(QTY) CONDLIST(GE)"
"ISPEXEC TBSCAN TORDER ARGLIST(QTY
TITLE) CONDLIST(GE EQ)"
Using TBSARG Command
Syntax:
"ISPEXEC TBSARG table-name
NAMECOND(var1,cond1,var2,cond2...)"
"ISPEXEC TBSCAN table-name"
Example
"ISPEXEC TBSARG TDOCS
NAMECOND(QTY,GE,TITLE,EQ)"
"ISPEXEC TBSCAN TDOCS"
Generic Search
• Use ‘*’ at the end of variable value.
• ‘*’ in the middle of a variable is considered as a part of search
value.
TBCLOSE Command
Syntax:
"ISPEXEC TBCLOSE table-name"
Dialog to Add Records
--------------------ADD A NEW DOCUMENT -----------------COMMAND ===>
DOCUMENT ID ===>
TITLE
===>
PRESS END KEY TO EXIT
Panel
Panel Definition
)ATTR
# TYPE(TEXT) INTENS(LOW) SKIP(ON)
)BODY
%-----------------------ADD A NEW DOCUMENT----------------------------%COMMAND ===> _ZCMD
%
+DOCUMENT ID ===> _DOCID #
+TITLE
===> _TITLE
%
%PRESS END KEY TO EXIT
)INIT
&DOCID=’ ‘
&TITLE=’ ‘
)PROC
VER(&DOCID,PICT,AANN-NNNN)
IF (&DOCID = ‘ ‘)
VER(&TITLE,NONBLANK)
)END
Procedure
/* REXX */
address ispexec
"LIBDEF ISPPLIB DATASET ID(TEST.PANELS)"
"LIBDEF ISPTLIB DATASET ID(TEST.TABLES)"
"LIBDEF ISPTABL DATASET ID(TEST.TABLES)"
"TBOPEN TDOCS"
do until Endkey = "YES"
DISPLAY PANEL(DOCADD)"
If rc = 8 then
Endkey = "YES"
If docid = "" then do
"TBADD TDOCS"
if rc = 0 then do
zedsmsg = "ROW ADDED"
zedlmsg = "DOCUMENT &DOCID ADDED TO TDOCS TABLE"
end
(contd.)
Procedure
else do
zedsmsg = "NOT ADDED"
zedlmsg = "AN ERROR HAS OCCURRED"
end
"SETMSG MSG(ISRZ001)"
end
end
"TBCLOSE TDOCS"
"LIBDEF ISPPLIB"
"LIBDEF ISPTLIB"
"LIBDEF ISPTABL"
exit
TBDISPL Command
• Used to interact with Display Services.
• Used to display the contents of a table in the panel defined.
Syntax
"ISPEXEC TBDISPL table-name
[PANEL(panel-name)]"
Dialog to browse table records
---------------------BROWSE DOCUMENTS ---------------------- ROW 1 OF 24
COMMAND ===>
SCROLL ===> DATA
SEARCH CRITERIA:
DOCUMENT ID ===> *
TITLE
===> *
DOCID TITLE
-----------------------------------------------------------------------------------------------------SC28-1875
TSO/E VERSION 2 PROGRAMMING SERVICES
SC28-1874
TSO/E VERSION 2 PROGRAMMING GUIDE
SC34-1871
ISPF AND ISPF/PDF GENERAL INFORMATION
………………………………………………………………………...
………………………………………………………………………..
SC34-1874
ISPF DIALOG MANAGER
SC34-1875
ISPF DIALOG MANAGEMENT EXAMPLES
SC34-1876
ISPF/PDF GUIDE
Part1 –(INITIAL PANEL DISPLAYED)
Dialog to browse table records
------------------------BROWSE DOCUMENTS ---------------------- ROW 14 OF 24
COMMAND ===>
SCROLL ===> DATA
SEARCH CRITERIA:
DOCUMENT ID ===> *
TITLE
===> *
DOCID TITLE
---------------------------------------------------------------------------------------------------SC28-1878
TSO/E VERSION 2 REXX REFERENCE
GC28-1887
TSO/E VERSION 2 PRIMER
………………………………………………………………...
………………………………………………………………..
SC28-18875
TSO/E VERSION 2 CUSTOMIZATION
SC28-1876
TSO/E VERSION 2 ADMINISTRATION
GC28-1877
TSO/E VERSION 2 LIBRARY GUIDE
*****************************BOTTOM OF DATA *******************************
Part2 – (USER PRESSED PF08)
Dialog to browse table records
------------------------BROWSE DOCUMENTS ---------------------- ROW 14 OF 24
COMMAND ===>
SCROLL ===> DATA
SEARCH CRITERIA:
DOCUMENT ID ===> *
TITLE
===> ISPF*
DOCID TITLE
---------------------------------------------------------------------------------------------------SC28-1878
TSO/E VERSION 2 REXX REFERENCE
GC28-1887
TSO/E VERSION 2 PRIMER
………………………………………………………………...
………………………………………………………………..
SC28-18875
TSO/E VERSION 2 CUSTOMIZATION
SC28-1876
TSO/E VERSION 2 ADMINISTRATION
GC28-1877
TSO/E VERSION 2 LIBRARY GUIDE
*****************************BOTTOM OF DATA *******************************
Part3 – (USER ENTER SEARCH CRITERIA)
Dialog to browse table records
------------------------BROWSE DOCUMENTS ---------------------- ROW 3 OF 14
COMMAND ===>
SCROLL ===> DATA
SEARCH CRITERIA:
DOCUMENT ID ===> *
TITLE
===> ISPF*
DOCID TITLE
---------------------------------------------------------------------------------------------------SC34-1874
ISPF DIALOG MANAGER
SC34-1875
ISPF DIALOG MANAGEMENT EXAMPLES
SC34-1876
ISPF/PDF GUIDE
SC34-1877
ISPF/PDF SERVICES
SC34-1878
ISPF/PDF LIBRARY MANAGEMENT
SC34-1879
ISPF/PDF EDIT AND EDIT MACROS
SC34-1880
ISPF/PDF PANEL DEFINITION
SC34-1881
ISPF/PDF SKELETONS
*****************************BOTTOM OF DATA *******************************
Part4 – (USER PRESSES ENTER KEY)
Browse dialog - Panel Definition
)ATTR
# TYPE(TEXT) INTENS(LOW) SKIP(ON)
@ TYPE(OUTPUT) INTENS(LOW)
)BODY
%------------------------- BROWSE DOCUMENTS -----------------------------------%COMMAND ===> _ZCMD
#SCROLL ===>_SCRO#
%
+SEARCH CRITERIA:
+DOCUMENT ID ===> _SDOCID #
+TITLE
===> _STITLE
+ DOCID
TITLE
+---------------------------------------------------------------------------------------------------)MODEL ROWS(SCAN)
@DOCID @TITLE
)INIT
&SCRO = DATA
.CURSOR = SDOCID
)END
Browse dialog - Procedure
/* REXX */
address ispexec
"LIBDEF ISPPLIB DATASET ID(TEST.PANELS)"
"LIBDEF ISPTLIB DATASET ID(TEST.TABLES)"
"TBOPEN TDOCS NOWRITE"
sdocid = "*"
stitle = "*"
do until Endkey = "YES"
Docid = sdocid
Title = stitle
"TBSARG TDOCS NAMECOND(DOCID,EQ,TITLE,EQ)"
"TBDISPL TDOCS PANEL(DOCBRWS)"
if rc = 8 then
Endkey = "YES"
end
"TBCLOSE TDOCS"
"LIBDEF ISPPLIB"
"LIBDEF ISPTLIB"
Dialog Processing Selected Rows
-------------DOCUMENT ORDER – ENTRY SCREEN ---------- ROW 1 OF 24
COMMAND ===>
SCROLL ===> DATA
EMPLOYEE NUMBER ===>
DEPARTMENT
===>
QTY DOCID
TITLE
------------------------------------------------------------------------------------------------------SC28-1875
TSO/E VERSION 2 PROGRAMMING SERVICES
SC28-1874
TSO/E VERSION 2 PROGRAMMING GUIDE
SC34-1871
ISPF AND ISPF/PDF GENERAL INFORMATION
………………………………………………………………………………..
SC34-1872
ISPF AND ISPF/PDF PLANNING
SC34-1873
ISPF AND ISPF/PDF PRIMER
SC34-1874
ISPF DIALOG MANAGER
PART-1: (DOCORDER dialog displays first 15 rows)
Dialog Processing Selected Rows
-------------DOCUMENT ORDER – ENTRY SCREEN ---------- ROW 18 OF 24
COMMAND ===>
SCROLL ===> DATA
EMPLOYEE NUMBER ===> 1234
DEPARTMENT
===> HR
QTY DOCID
TITLE
------------------------------------------------------------------------------------------------------SC28-1875
SC28-1874
1
SC34-1871
1
SC34-1872
SC34-1873
SC34-1874
*************************
TSO/E VERSION 2 PROGRAMMING SERVICES
TSO/E VERSION 2 PROGRAMMING GUIDE
ISPF AND ISPF/PDF GENERAL INFORMATION
ISPF AND ISPF/PDF PLANNING
ISPF AND ISPF/PDF PRIMER
ISPF DIALOG MANAGER
BOTTOM OF DATA ************************************
PART-2: (User scrolls by PF08 and selects two rows)
Docorder - Panel Definition
)ATTR
# TYPE(TEXT) INTENS(LOW) SKIP(ON)
@ TYPE(OUTPUT) INTENS(LOW)
)BODY
%-----------------DOCUMENT ORDER – ENTRY PANEL---------------------------%COMMAND ===> _ZCMD
#SCROLL ===>_SCRO#
+EMPLOYEE NUMBER
===> _EMPNO #
+DEPARTMENT ===> _DEPT#
+ QTY
DOCID
TITLE
+----------------------------------------------------------------------------------------------------)MODEL
_QTY# @DOCID
@TITLE
)INIT
&SCRO = DATA
)PROC
IF (&ZTDSELS > 0000 )
VER(&QTY,NUM)
)END
Docorder - Procedure
/* REXX */
"ALLOCATE DDNAME(ORDER) DSNAME(ORDER.DATA) MOD"
address ispexec
"LIBDEF ISPPLIB DATASET ID(USER.PANELS)"
"LIBDEF ISPTLIB DATASET ID(USER.TABLES)"
"TBOPEN TDOCS NOWRITE"
"TBDISPL TDOCS PANEL(DOCORDER)"
if ztdsels > 0 then
queue Empno Dept Docid Qty
do while ztdsels > 1
"TBDISPL TDOCS"
if ztdsels > 0 then
queue Empno Dept Docid Qty
end
(contd.)
Docorder - Procedure
zedsmsg = "ORDER PLACED"
zedlmsg = "YOUR ORDER WAS WRITTEN TO ORDER FILE"
"SETMSG MSG(ISRZ000)"
queue
address tso
"EXECIO * DISKW ORDER (FINIS"
"FREE DDNAME ORDER"
address ispexec
"TBCLOSE TDOCS"
"LIBDEF ISPPLIB"
"LIBDEF ISPTLIB"
Download