Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2
Sequentially Processing
a KSDS
3
File-Control for
Sequential KSDS
File-Control.
SELECT file-name
ASSIGN to ddname
ORGANIZATION is INDEXED
ACCESS MODE is SEQUENTIAL
RECORD KEY is data-name-1
FILE STATUS is data-name-2.
4
File-Control for
Sequential KSDS
• File-Control.
SELECT file-name
where file-name is the name used for the
file throughout the program
5
File-Control for
Sequential KSDS
• File-Control.
ASSIGN to ddname
where ddname is the ddname in the JCL
used to refer to the KSDS file
6
File-Control for
Sequential KSDS
• File-Control.
ORGANIZATION is INDEXED
where INDEXED specifies that this file is
a KSDS
7
File-Control for
Sequential KSDS
• File-Control.
ACCESS MODE is SEQUENTIAL
where SEQUENTIAL specifies that the
processing of the KSDS will be in
order on the key field of the file
8
File-Control for
Sequential KSDS
• File-Control.
RECORD KEY is data-name-1
where data-name-1 is the file’s key field
and the records are going to be
accessed ascending on this field
9
File-Control for
Sequential KSDS
• File-Control.
FILE STATUS is data-name-2
where data-name-2 is a filed you specify
in which VSAM provides information
about each I/O operation
VSAM places a return code in data-name-2
for the application program to determine
the result of the I/O operation
10
Common File Status for KSDS
Code Meaning
00 Successful completion
10 End of file reached
21 Sequence error
22 Duplicate key
23 Record not found
24 No more space
11
FD Statement in KSDS
FD KSDS-file
LABEL RECORDS ARE [OMITTED
or STANDARD].
12
Procedure Division in
KSDS Sequential Processing
• OPEN statement
• START statement
• READ statement
• WRITE statement
• REWRITE statement
• DELETE statement
• CLOSE statement
13
KSDS OPEN Statement
14
KSDS START Statement
• START statement
– Used to start sequential processing with a
record other than the first record in the file
– Use with a file that is opened as input or
dynamically (I-O) and processing
sequentially
– To use, place a value in the record key
area
15
KSDS START Statement
• START statement
START vsam-file
[KEY IS {EQUAL TO
=
GREATER THAN
>
NOT LESS THAN
NOT <
GREATER THAN OR EQUAL TO
>= }
record-key]
[INVALID KEY imperative-1]
KEY imperative-2]
[NOT INVALID
[END-START] 16
KSDS READ Statement
• READ statement (sequential)
– To retrieve records in key sequence, open
KSDS for either
• INPUT or
• I-O
17
KSDS READ Statement
• READ statement (sequential)
18
KSDS READ Statement
• READ statement (sequential)
19
KSDS READ Statement
• READ statement (sequential)
– The key using dynamic access is knowing
how to switch from sequential to random
access.
– The position for sequential retrieval is
changed only by a START or a random
READ statement.
20
KSDS READ Statement
• READ statement (sequential)
– A random READ statement can be used to
retrieve a specific record and then can be
followed by a sequential READ statement
(using the NEXT option)
21
KSDS WRITE Statement
22
KSDS WRITE Statement
23
KSDS WRITE Statement
25
KSDS REWRITE Statement
26
KSDS REWRITE Statement
27
KSDS DELETE Statement
28
KSDS DELETE Statement
29
KSDS DELETE Statement
30
KSDS CLOSE Statement
31
KSDS Load Program
in COBOL
• Go over handout
“COBOL JCL
& Source Review for Loading KSDS”
32
KSDS Random Processing
33
File-Control for
Random KSDS
File-Control.
SELECT file-name
ASSIGN to ddname
ORGANIZATION is INDEXED
ACCESS MODE is RANDOM
RECORD KEY is data-name-1
FILE STATUS is data-name-2.
34
File-Control for
Random KSDS
File-Control.
ACCESS MODE is RANDOM
35
Procedure Division in
KSDS Random Processing
• OPEN statement
• READ statement
• WRITE statement
• REWRITE statement
• DELETE statement
• CLOSE statement
36
KSDS OPEN Statement
37
KSDS READ Statement
38
KSDS READ Statement
39
KSDS READ Statement
40
KSDS READ Statement
[KEY IS data-name-1]
41
KSDS READ Statement
43
KSDS WRITE Statement
44
KSDS REWRITE statement
45
KSDS REWRITE statement
46
KSDS DELETE Statement
47
KSDS DELETE Statement
48
KSDS CLOSE Statement
49
KSDS Dynamic Processing
50
KSDS Dynamic Processing
51
KSDS Dynamic Processing
• Note:
– During dynamic processing issuing a
WRITE, REWRITE, or DELETE statement
does not change file position
– Use START or random READ to change
file position
52
File-Control for
Dynamic KSDS
File-Control.
SELECT file-name
ASSIGN to ddname
ORGANIZATION is INDEXED
ACCESS MODE is DYNAMIC
RECORD KEY is data-name-1
FILE STATUS is data-name-2
53
KSDS READ Statement
54
KSDS READ Statement
55