Presentation is loading. Please wait.

Presentation is loading. Please wait.

File Handling & Temporary Storage Day4 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Objectives Access Methods –VSAM.

Similar presentations


Presentation on theme: "File Handling & Temporary Storage Day4 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Objectives Access Methods –VSAM."— Presentation transcript:

1

2 File Handling & Temporary Storage Day4

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

4 3 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

5 4 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

6 5 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

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

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

9 8 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.

10 9 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.

11 10 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.

12 11 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.

13 12 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.

14 13 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.

15 14 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Sequential access - Browsing STARTBR READNEXT READPREV RESETBR ENDBR

16 15 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.

17 16 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.

18 17 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.

19 18 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.

20 19 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

21 20 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)

22 21 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.

23 22 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

24 23 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.

25 24 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

26 25 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 EXEC CICS DELETEQ TD QUEUE (qname) END-EXEC DFHDCT entry TYPE=INTRA DESTID=qname TRANSID=EMPL TRIGLEV=2000

27 26 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?

28 27 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Thank You!


Download ppt "File Handling & Temporary Storage Day4 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/TP01/003 Version No: 1.0 Objectives Access Methods –VSAM."

Similar presentations


Ads by Google