File Handling & Temporary Storage Day4 2 Copyright © 2005, Infosys Technologies Ltd...

Preview:

Citation preview

File Handling & Temporary StorageDay4

2Copyright © 2005, Infosys Technologies Ltd

ER/CORP/CRS/TP01/003 Version No: 1.0

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

3Copyright © 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

4Copyright © 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

5Copyright © 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

6Copyright © 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

7Copyright © 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.

8Copyright © 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.

9Copyright © 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.

10Copyright © 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.

11Copyright © 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.

12Copyright © 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.

13Copyright © 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.

14Copyright © 2005, Infosys Technologies Ltd

ER/CORP/CRS/TP01/003 Version No: 1.0

Sequential access - Browsing• STARTBR

• READNEXT

• READPREV

• RESETBR

• ENDBR

15Copyright © 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.

16Copyright © 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.

17Copyright © 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.

18Copyright © 2005, Infosys Technologies Ltd

ER/CORP/CRS/TP01/003 Version No: 1.0

ENDBR

• End browse operation

EXEC CICS ENDBR

FILE (‘EMPFILE’)

END-EXEC.

19Copyright © 2005, Infosys Technologies Ltd

ER/CORP/CRS/TP01/003 Version No: 1.0

Sequential access – VSAM ESDSMove 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

20Copyright © 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)

21Copyright © 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.

22Copyright © 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

23Copyright © 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.

24Copyright © 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

25Copyright © 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

EXEC CICS DELETEQ TD

QUEUE (qname)

END-EXEC

DFHDCT entry

TYPE=INTRA

DESTID=qname

TRANSID=EMPL

TRIGLEV=2000

26Copyright © 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?

27Copyright © 2005, Infosys Technologies Ltd

ER/CORP/CRS/TP01/003 Version No: 1.0

Thank You!

Recommended