PPT_TP01_CICS_04

advertisement
File Handling & Temporary
Storage
Day4
Objectives
• Access Methods
– VSAM
– BDAM
• VSAM Considerations
– Random access
– Sequential access
• Temporary Storage Control
– Commands to read, write and delete
– Design considerations
– Examples
• Transient Data Control
–
–
–
–
Intrapartition TD queues
Extrapartition TD queues
Commands to read, write and delete
Examples
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
CICS File Control
• VSAM
– Allows read, browse, update and delete operations
• BDAM
– Allows read, browse and update only
– They are less efficient than VSAM
– Can be replaced by a relative record VSAM dataset or ESDS addressed by
RBA
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
Types of VSAM Files
• ESDS - Entry Sequenced Data Set
• KSDS - Key Sequential Data Set
• RRDS - Relative Record Data Set
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
Alternate Indexes in VSAM
•
•
•
•
Accessing same set of records in different ways
Any number of alternate keys
Alternate keys need not be unique
Only KSDS and ESDS can have alternate keys
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
Random access - READ
MOVE +80 TO WS-EMP-REC-LEN.
MOVE ‘10000’ TO WS-EMP-REC-KEY.
MOVE 5 TO WS-EMP-KEY-LEN.
EXEC CICS READ
FILE (‘EMPFILE1’)
INTO (WS-EMP-REC)
LENGTH (WS-EMP-REC-LEN)
RIDFLD (WS-EMP-REC-KEY)
KEYLENGTH (WS-EMP-KEY-LEN)
END-EXEC.
• Places the record in WS-EMP-REC
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
GENERIC READ
MOVE +80 TO WS-EMP-REC-LEN.
MOVE ‘10’ TO WS-EMP-REC-KEY.
MOVE 2 TO WS-EMP-KEY-LEN.
EXEC CICS READ
FILE (‘EMPFILE1’)
INTO (WS-EMP-REC)
LENGTH (WS-EMP-REC-LEN)
RIDFLD (WS-EMP-REC-KEY)
KEYLENGTH (WS-EMP-KEY-LEN)
GENERIC
END-EXEC.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
READ Continues...
• READ COMMAND OPTIONS
– EQUAL
– GTEQ
– UPDATE
• READ-UPDATE/REWRITE
– Maintains exclusive control on the resource(on CI in case of
VSAM file) until
• REWRITE is done
• Transaction ends normally or abnormally
• Control over resource is released by program using UNLOCK command.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
REWRITE
• To rewrite records into file.
EXEC CICS REWRITE
FILE (‘EMPFILE’)
FROM (WS-EMP-REC)
LENGTH (WS-EMP-REC-LEN)
END-EXEC.
• This command updates a record.
• Prior to this command the record must be read
with a READ UPDATE command.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
WRITE
• To write records into file.
MOVE +80 TO WS-EMP-REC-LEN.
MOVE ‘11000’ TO WS-EMP-REC-KEY.
MOVE 5 TO WS-EMP-KEY-LEN.
EXEC CICS WRITE
FILE (‘EMPFILE’)
FROM (WS-EMP-REC)
LENGTH (WS-EMP-REC-LEN)
RIDFLD (WS-EMP-REC-KEY)
KEYLENGTH (WS-EMP-KEY-LEN)
END-EXEC.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
DELETE
• Read the record with UPDATE option and then
delete it with the following command.
EXEC CICS DELETE
FILE(‘EMPFILE’)
END-EXEC.
• Use the following command to delete the record
directly.
MOVE ‘12345’ TO EMP-REC-KEY.
EXEC CICS DELETE
FILE(‘EMPFILE’)
RIDFLD (EMP-REC-KEY)
END-EXEC.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
GROUP DELETE
• MOVE ‘11’ TO WS-EMP-REC-KEY.
• MOVE 2 TO WS-EMP-KEY-LEN.
EXEC CICS DELETE
FILE (‘EMPFILE’)
RIDFLD (WS-EMP-REC-KEY)
KEYLENGTH (WS-EMP-KEY-LEN)
GENERIC
NUMREC (WS-NUM-REC-DEL)
END-EXEC.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
Transaction deadlocks
• Exclusive control on CI.
• Exclusive control may cause transaction
deadlocks. Make sure to use UNLOCK when
you are not rewriting
• In pseudo-conversation, at the end of
transaction, all locks are released.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
Sequential access - Browsing
•
•
•
•
•
STARTBR
READNEXT
READPREV
RESETBR
ENDBR
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
STARTBR
• This establishes a browse session.
EXEC CICS STARTBR
FILE (‘EMPFILE’)
RIDFLD (EMP-REC-KEY)
KEYLENGTH(KEY-LEN)
GTEQ/EQUAL/GENERIC
END-EXEC.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
READNEXT/READPREV
EXEC CICS READNEXT/READPREV
FILE (‘EMPFILE’)
INTO (EMP-REC)
LENGTH (EMP-REC-LEN)
RIDFLD (EMP-REC-KEY)
END-EXEC.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
RESETBR
• Establish a new browsing position with in the
same browse.
MOVE ‘12345’ TO EMP-REC-KEY.
EXEC CICS RESETBR
FILE (‘EMPFILE’)
RIDFLD (EMP-REC-KEY)
GTEQ
END-EXEC.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
ENDBR
• End browse operation
EXEC CICS ENDBR
FILE (‘EMPFILE’)
END-EXEC.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
Sequential access – VSAM ESDS
Move Low-values to VSAM-ESDS-RBA
EXEC CICS STARTBR
DATASET (‘filename’)
RIDFLD(ESDS-RBA)
RBA
EQUAL
END-EXEC
EXEC CICS READNEXT
DATASET (‘filename’)
INTO(FILE-AREA)
RIDFLD(ESDS-RBA)
LENGTH(WS-LEN)
RBA
END-EXEC
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
Temporary Storage
•
•
•
•
•
COMMAREA (Communication Area)
CWA (Common Work Area)
TWA (Transaction Work Area)
TSQ (Temporary Storage Queue)
TDQ (Transient Data Queue)
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
TSQ Commands
• WRITEQ TS
EXEC CICS WRITEQ TS
QUEUE (qname)
FROM (recarea)
LENGTH (length)
option (option)…
END-EXEC.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
TSQ Commands
• READQ TS
EXEC CICS READQ TS
QUEUE (qname)
INTO (recarea)
LENGTH (length)
option
END-EXEC
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
TSQ Commands
• DELETEQ TS
EXEC CICS DELETEQ TS
QUEUE (qname)
END-EXEC.
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
Transient Data Queue
• 2 types of TDQ
– Intra-partition
– Extra-partition
• Difference between TDQ and TSQ
–
–
–
–
–
–
TDQ to be defined in DCT
No modify or Rewrite option in TDQ
TDQ can be read only sequentially
A destructive read is performed on TDQ
A trigger can be set on Intrapartition TDQ
No counterpart to the MAIN option available in TSQ
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
TDQ Commands
EXEC CICS WRITEQ TD
QUEUE (qname)
FROM (recarea)
LENGTH (length)
END-EXEC
EXEC CICS READQ TD
QUEUE (qname)
INTO (recarea)
LENGTH (length)
END-EXEC
DFHDCT entry
EXEC CICS DELETEQ TD
QUEUE (qname)
END-EXEC
TYPE=INTRA
DESTID=qname
TRANSID=EMPL
TRIGLEV=2000
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
Summary
• What is VSAM?
• What are the types of VSAM files?
• When do transaction deadlocks happen and how
to avoid?
• What are the commands for sequential access?
• How is sequential access of ESDS done?
• What is the difference between TSQ and TDQ?
• What are the commands used to access TSQ and
TDQ?
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
Thank You!
Copyright © 2005,
‹#›
Infosys Technologies Ltd
ER/CORP/CRS/TP01/003
Version No: 1.0
Download