1. What are the different
types of VSAM files available?
A. ESDS: Entry Sequence Data Set, KSDS: Key Sequence Data Set, RRDS: Relative Data Set
2. What is IDCAMS ?
A. IDCAMS is the Access Method Services program.
You run the IDCAMS program and supply AMS commands through SYSIN. (examples of
AMS commands are DELETE, DEFINE, REPRO etc..).
3. Syntax of AMS modal
commands ? Note: these can be used only under IDCAMS and not from the TSO
prompt.
A. IF LASTCC(or MAXCC) >(or <,= etc..)
value -
THEN -
DO
-
command
set (such as DELETE, DEFINE etc..)
ELSE
-
DO
-
command
set
LASTCC
- Condition code from the last function(suuch as delete) executed
MAXCC
- Max condition code that was returned by any of the previous functions
SET is also a
valid AMS command. SET LASTCC (or MAXCC) = value
The maximum
condition code is 16. A condition code of 4 indicates a warning. A condition
code of 8 is usually Encountered on a DELETE of a dataset that is not present.
4. Under IDCAMS , multiple
functions can be executed, each of which returns a condition code. What will be
the condition code returned to the operating system?
A. The maximum condition code generated is
returned as the condition code of the IDCAMS step.
5. What is Control Interval,
Control Area?
A. Control Interval is analogous to a physical
block for QSAM files. It is the unit of i/o. Must be between 512 bytes to 32 k.
Usually either 2K or 4K. A larger control interval increases performance for
sequential processing while the reverse is true for random access. Under CICS
when a record is locked, the entire CI gets locked. Control area is a
group of control intervals. CA is used during allocation. CA size is calculated
based on the allocation type (cyl, tracks or records) and can be max of 1
cylinder.
6. What is FREESPACE ?
A. Coded in the DEFINE as FREESPACE(ci ca) where
ci is the percentage of each control interval to be left free for insertions,
ca is the percentage of control intervals in each control area to be left
empty.
7. How do you decide on
optimum values for CI, FREESPACE etc...
A. CI size should be based on record length,
type of processing. Usually CI is 4K. If record length is larger(>1K), chose
6K or 8K.
FREESPACE
should be large if more number of insertions are envisaged. Usual values are
(20 20) when heavy updates are expected. CI size can be calculated.
8. Would you specify
FREESPACE for an ESDS?
A. No. Because you cannot insert records in an
ESDS, also when you rewrite a record, it must be of the same length. Thus
putting any value for freespace does not make any sense.
9. What is SHAREOPTS ?
A. SHAREOPTS is a parameter in the DEFINE and
specifies how an object can be shared among users. It is coded as SHAREOPTS(a
b), where a is the cross region share option ie how two or more jobs on a
single system can share the file, while b is the cross system share option ie
how two or more jobs on different MVS 's can share the file. Usual value is (2
3).
10. What is the meaning of
each of the values in SHAREOPTS(2 3)?
A. Value of 2 for cross region means that the
file can be processed simultaneously by multiple users provided only one of
them is an updater. Value of 3 for cross system means that any number of jobs
can process the file for input or output (VSAM does nothing to ensure
integrity).
11. How do you define a KSDS
?
A. DEFINE CLUSTER(cluster name) with the INDEXED
parameter. Also specify the ds-name for the DATA component & the dataset
INDEX component. Other important parameters are RECORDSIZE, KEYS, SHAREOPTIONS.
12. Can AMS commands be run
from the TSO prompt?
A. Yes
13. How do you define an
ALTINDX ? How do you use ALTINDXs in batch, CICS programs ?
·
DEFINE ALTERNATEINDEX. Important parameters are RELATE where
you specify the base cluster name, KEYS, RECORDSIZE,SHAREOPTIONS,UNIQUEKEY(or
NONUNIQUEKEY), DATA(ds-name for the data component), INDEX(ds-name for the
index component).
·
Then DEFINE PATH. Important parameters are NAME (ds-name for
the path), PATHENTRY (ds-name of the alternate index name), UPDATE(or NOUPDATE)
which specifies whether an alt index is updated when a update to the base
cluster takes place.
·
Then BLDINDEX. Parameters are INDATASET(ds-name of base
cluster), OUTDATASET(ds-name of AIX). If you use INFILE or OUTFILE specify the
dd-name after declaring it in JCL.
·
Using alternate indexes in batch programs:
In the JCL,
you must have DD statements for the cluster and for the path(s). In the Cobol
program, SELECT .. ASSIGN TO dd-name for base cluster RECORD KEY IS...
ALTERNATE RECORD KEY IS..
·
Using alternate indexes in CICS programs:
FCT entries
must be created for both base cluster & the path. To read using the
alternate index, use the dd-name of the path in CICS file control commands.
14. What happens when you
open an empty VSAM file in a COBOL program for input?
A.
VSAM file that has never contained a
record is treated as unavailable. Attempting to open for input will fail. An
empty file can be opened for output only. When you open for output, COBOL will
write a dummy record to the file & then delete it out.
15. How do you initialize a
VSAM file before any operation? a VSAM with alternate index?
A. Can write a dummy program that just opens the
file for output & then closes it.
16. What does a file status
of 02 on a VSAM indicate?
A. Duplicate alternate key . Happens on both
input and output operation
17. How do you calculate
record size of an alternate cluster? Give your values for both unique and
non-unique?
A. Unique Case: 5 + ( alt-key-length +
primary-key ). Nonunique Case: 5 + (
alt-key-length + n * primary-key ). Where
n = # of duplicate records for the alternate key
18. What is the difference
between sequential files and ESDS files?
A. Sequential (QSAM) files can be created on
tape while ESDS files cannot. Also, you can have ALTINDEX for an ESDS while no
such facility exists for QSAM files.
19. How do you load a VSAM
data set with records?
A. Using the REPRO command.
20. How do you define a GDG ?
A. Use the DEFINE GENERATIONDATAGROUP command.
In the same IDCAMS step, another dataset must be defined whose DCB parameters are
used when new generations of the GDG are created. This dataset is known as the
model dataset. The ds-name of this model dataset must be the same as that of
the GDG, so use a DISP of KEEP rather than CATLG and also specify SPACE=(trk,0)
21. Do all versions of the
GDG have to be of the same record length ?
A. No, the DCB of the model dataset can be
overridden when you allocate new versions.
22. How are different
versions of GDG named?
A. Base-file-name.GnnnnnV00 where nnnn=
generation number (upto 255). nnnn will be 0000 for the 1st generation. This
format is also called as Absolute GDG naming format.
23. Suppose 3 generations of
a GDG exist. How would you reference the 1st generation in the JCL?
A. Use GDG name(-2). It is relative naming
format.
24. Suppose a generation of
GDG gets created in a particular step of a PROC. How would you refer the
current generation in a subsequent step? What would be the disposition of this
generation now?
A. Relative generation numbers are updated only
at the end of the job, not at the end of a step. To allocate a new generation,
we would be using (+1) with a DISP of (NEW,CATLG,DELETE). To refer to this in a
subsequent step in the same job, we would again use (+1) but with a DISP of SHR
or OLD.
25. What more info you should
give in the DD statement while defining the next generation of a GDG?
A. Give (+1) as the generation number, give
(new,catlg) for DISP, give space parameter, can give the Dataset Control Block
parameter if you want to override the DCB of the model dataset.
26. Assuming that the DEFINE
JCL is not available, how do you get info about a VSAM file's organization ?
A, Use the LISTCAT command.
27. During processing of a
VSAM file, some system error occurs and it's subsequently unusable. What do you
do?
A. Run VERIFY.
28. How do you fix the
problem associated with VSAM out of space condition?
Answer:
1. Define new VSAM dataset allocated with more space. 2. Use IDCAMS to REPRO
the old VSAM file to new VSAM dataset. 3. Use IDCAMS to ALTER / rename the old
VSAM dataset or se IDCAMS to DELETE the old VSAM dataset. 4. Use IDCAMS to
ALTER / rename the new VSAM dataset to the name of the original VSAM dataset.
29. What is the meaning of
VSAM RETURN-CODE 28?
A. Out of space condition is raised.
30. How many Alternate
Indexes you can have on a dataset? - Remember ALT INDEX is possible only on
KSDS and RRDS.
A. 255 - but you must be a nut to have so many
ALT Indexes on a dataset!
31. Is it slower if you
access a record through ALT INDEX as compared to Primary INDEX? Why?
A. Yes. Because the alternate key would first
locate the primary key, which in turn locates the actual record. Needs twice
the number of I/Os.
32. What is RECOVERY and
SPEED parameters in DEFINE CLUSTER command?
A. RECOVERY
(default) and SPEED are mutually exclusive. Recovery pre-formats the control
areas during the initial dataset load, if the job fails, you can restart but
you must have a recovery routine already written to restart the job. SPEED does
not pre-format the CAs. It is recommended that you specify SPEED to speed up
your initial data load.
33. What is a Base Cluser?
A. The Index and data components of a KSDS
34. Describe SHAREOPTIONS
parameter (SHR) in Define Cluster command.
A. It defines the cross-region and cross-system
sharing capabilities of the dataset. Syntax is SHR(CRvalue CSvalue) value 1
means multiple read OR single write (read integrity) 2 means multiple read AND
single write (Write integrity) 3 means Multiple read AND multiple write 4 is
same as 3, which refreshes the buffer with every random access. default is
SHR(1 3).
35. What does the KEYRANGES
parameter in Define Cluster commend do?
A. It divides a large dataset into several
volumes according to the Key-ranges specified. e.g., KEYRANGES ((0000001
2999999) (3000000 5999999)). if the activity on the key ranges are evenly
distributed, cuncurrent access is possible, which is a performance improvement.
36. What are the optional
parameters to the input dataset While loading the empty cluster with the data
records?
A. 1)FROMADDRESS(address)
2)TOADDRESS(address) where 'address' specifies the RBA value of the key of the
input record. 3)FROMNUMBER(rrn) 4)TONUMBER(rrn) where 'rrn' specifies the
relative record number of the RRDS record 5)FROMKEY(key) 6)TOKEY(key) where
'key' specifies the key of the input record 7)SKIP(number) 8)COUNT(number)
where 'number' specifies the number of records to skip or copy Ex: REPRO
INFILE(DD1) OUTFILE(DD2) SKIP(9000) COUNT(700) - Skips the first 9000 records
and begins copying at 9001 and copies 700 records from DD1 to DD2.
37. What is IDCAMS? What is
the purpose of it?.
A. IDCAMS is an access method services utility
used for creating, deleting, altering VSAM files and copying sequential file to
a VSAM file, etc.
38. How to delete a member
using JCL.
A. Using IDCAMS a member can be deleted. DELETE
'XXX.YYY(member)
39. What is the Difference
between LDS & ESDS ?
A. These two datasets are VSAM datasets. ESDS
maintains control information. But LDS does not maintains the control information.
40. A) Is a delete operation
possible in an ESDS? B) Is rewrite operation possible in ESDS ?
A. A. No delete operation is not possible in
VSAM ESDS. B. Yes rewrite operation is possible in an ESDS.
41. What is an alternate
index and path ?
A. An alternate index is an another way of
accessing key sequenced data record stored in a base cluster and path is the
linkage which connect alternate index to its base cluster.
42. How many buffers are
allocated to VSAM KSDS and ESDS?
A. 2 data buffers by default for ESDS. For KSDS
it allots 2 data buffers and 1 index buffers. each buffer is about 4k.
43. What's the biggest
disadvantage of using a VSAM dataset?
A. FREE SPACE(FPSC)
44. What's the device
independent method to indicate where a Record is Stored?
A. By USING RBA(Relative Byte Address).
45. How many times Secondary
Space Allocated?
A. 122 TIMES
46. What is the RRN for the
first record in RRDS?
A. 1
47. If FSPC(100 100) is
specified does it mean that both the control interval and control area will be
left empty because 100 % of both CI and CA are specified to be empty?
A. No, they would
not be left empty. One record will be written in each CI and 1 CI will be
written for each CA.
48.
VSAM NOTES FOR 1st time user.
To keep track of the files, all VSAM files need to be catalogued in a User catalogue or the Master catalogue. Each system can have only one Master catalog but a number of User catalog's. All User catalog's must be defined in the master catalog. The data in the VSAM files is stored in the Data component.
A KSDS have a data component that stores the file record's and the Indexed component that keeps track of each record's location based upon the Key Field in the data component. The data in KSDS can be accessed either sequentially or randomly. The index component of a KSDS has two parts: a sequence set, the lowest level of index component containing the relations between the key values to specific control intervals in data component and the index set consisting of one or more levels. The highest level of index set always has just one record, and the records of the lowest level of index set contains pointers to sequence set records. For each control area in the data component of a KSDS, there is one record in the sequence set. Then each sequence set record contains an index entry for each control interval in the corresponding control Area. That index entry is the highest key value stored in the corresponding CI. Notice that the sequence records also contains the free pointers. A typical index set record is of 512 bytes long, which is enough for up to 58 sequence records, many key sequenced datasets require just one index set record. Since each sequence record contains a control area, which is typically a full cylinder, A single index set record provides for up to 58 cylinders of data, which on a 3350 DASD volume is about 32 MB of data. If the file is larger than 32MB VSAM will automatically create another Index Set record as needed, and arrange them in appropriate levels. First VSAM reads and searches the index set record to determine which sequence set record to use. Then it reads the correct sequence set record the control interval to use. Finally, it reads and searches the control interval to locate the correct data record.
A KSDS can have free space reserved within its data component to accommodate new records. You can reserve this space either by leaving a certain portion of a Control interval free and by leaving entire control interval free, while defining the KSDS Cluster by using the AMS. VSAM stores logical records in key sequence in the data area. If there isn't enough space in the control Interval, when you add a record, VSAM performs control Interval split by moving some of the records in the control interval to a one of the free control interval. If there is not enough free control interval then VSAM performs Control Area split, by moving half of the control intervals into the new Control area, and then performing the control interval split by using the freed control intervals.
An alternate index let's you access the records by fields other then the primary key. The Base cluster consists of the data component and the index component for the primary index. Alternate Index component is created by associating the alternate key with the corresponding Primary key values. The Alternate Key could be a unique or non-unique key in data. When you process Alternate index with duplicate keys randomly, VSAM will retrieves only the first base cluster record for each alternate key. So, for duplicate alternate keys it is preferable to read them sequentially. An Alternate index is itself a KSDS. VSAM does not upgrade the alternate index, each and every time the base cluster is changed, until you specify AMS to upgrade the alternate index automatically, as it is a over head to the system.
The ESDS is used for only sequential processing of data in a dataset. The records are always added at the end of the dataset. In other words it only contains the Data Component, which is read always from the beginning, until the desired record is read. In general an ESDS is used in shops to collect all the transactions for the day, and batch processed at the end of the day to update the Master File or generate necessary reports.
A RRDS contains of a specified number of areas. Each of these areas are called a slot, can contain one record and is identified by a RRN (relative record number), that it indicates it's relative position in the file. For ex. the RRN for the record in ninth slot is '9' whether or not slot's 1 through 8 contain any records. The RRN identifies the slots, but not the records. A record in a RRDS can be accessed either sequentially or randomly. Unlike the KSDS the RRDS does not have an index, instead relative organization depends on a direct relationship between the data in each record and it's relative position (displacement) in the file. In some applications you use a field serial # in the record to match the RRN, or convert a field like Employer # to derive the RRN. Though, there is no apparent relationship between RRN and the key fields.
File Status Code |
OPEN |
CLOSE |
READ |
WRITE
|
REWRITE |
DELETE
|
START
|
Recommended
Program action |
00 |
OK |
OK |
OK
|
OK
|
OK |
OK
|
OK
|
Continue. |
02 |
- |
-
|
Valid
duplicate Alt key follows |
Valid duplicate Alt key created |
Valid duplicate
Alt key created |
|
|
Continue. During
Read use seq process till '00'. |
10 |
- |
- |
EOF |
- |
- |
- |
- |
Noraml AT END process |
21 |
|
|
|
Record
out of sequence (seq access only) |
|
|
|
Print
error message and continue. |
22 |
- |
- |
- |
Duplicate
Key |
- |
- |
- |
Error
message and continue. |
23 |
- |
- |
Record
not found |
- |
- |
Record
not found |
Key
not found |
Error
message and continue. |
24 |
- |
- |
- |
Out
of space |
- |
- |
- |
Terminate
Job |
30 |
Uncorrectable
I/O |
Uncorrectable
I/O |
Uncorrectable
I/O |
Uncorrectable
I/O |
Uncorrectable I/O |
Uncorrectable
I/O |
Uncorrectable
I/O |
Terminate
Job |
90 |
Unusable
file. Empty file opened for I/O |
VSAM logic error |
VSAM logic error |
VSAM logic error |
VSAM logic
error |
VSAM
logic error |
VSAM
logic error |
Terminate
Job |
91 |
Password
failure |
- |
- |
- |
- |
- |
- |
Terminate
Job |
92 |
File
already opened |
File
not open |
File
not open / EOF |
File
not open; incorrect key |
File not open / no previous read |
File
not open / no previous read |
Invalid
request / File not open |
Terminate
Job |
93 |
Not
enough Virtual storage for VSAM task |
Or
file contention problem |
-do
- open/close |
-do
- open/close |
-do - open/close |
-do
- open/close |
-do
- open/close |
Terminate
Job |
95 |
Conflicting
file attributes |
- |
- |
- |
- |
- |
- |
Terminate
Job |
96 |
No
DD or DLBL stmt |
- |
- |
- |
- |
- |
- |
Terminate
Job |
97 |
File
not closed by previous job. |
|
|
|
|
|
|
Terminate
Job |
VSAM code field is used to retrieve VSAM errors occurred during the process of the dataset.
01 VSAM-CODE FIELD COMP.
02 VSAM-RETURN-CODE PIC 9(2).
02 VSAM-FUNCTION-CODE PIC 9(2).
02 VSAM-FEEDBACK-CODE PIC 99.
A return code of '0' indicates the request had been successfully completed, '4' - A request is already active for the file specified, '8' - Logical error occurred; check feedback code for specifications. '12' - Physical error occurred; check the feed back code for specific information.
Function codes. '0' / '1' - An attempt was made to access the base cluster. '0' - status of upgrade set is correct. '1' - status of upgrade may be incorrect. '2' / '3' an attempt was made to access an alternate index of base cluster. '2' - status of upgrade set is correct. '3' - status of upgrade may be incorrect. . '4' / '5' an attempt was made to update the upgrade set for a base cluster. '4' - status of upgrade set is correct. '5' - status of upgrade may be incorrect.
CI is unit of data transferred between Virtual and Auxiliary storage memory.
Environment Division. Input-Output Section. File-Control.
SELECT file-name
ASSIGN TO system-name
ORGNAIZATION IS INDEXED
ACCESS MODE IS {SEQUENTIAL / RANDOM / DYNAMIC}
RECORD KEY IS data-name-1
[ ALTERNATE RECORD KEY IS data-name-3 [WITH DUPLICATES ]] ...
[ FILE STATUS IS data-name-2 [vsam-code]]
Data Division. File Section.
FD file-name
LABEL RECORDS ARE STANDARD
[ RECORD CONTAINS integer CHARACTERS ]
01 File-Record-Layout PIC ...
Procedure Division.
OPEN { INPUT / OUTPUT / I-O } File-name ...
START file-name [KEY IS { = / > / >= / EQUAL TO / GREATER THAN / NOT LESS THAN...} data-name]
[ INVALID KEY imperative-statement ]
READ file-name [ NEXT ] RECORD
[ INTO identifier ]
[ AT END imperative-statement ] [NOT AT END imperative-statement] END-READ
WRITE record-name
[ FROM identifer ]
[ INVALID KEY imperative-statement ] [NOT INVALID KEY imperative-statement] END-WRITE
REWRITE record-name
[ FROM identifer ]
[ INVALID KEY imperative-statement ] END-REWRITE
DELETE file-name RECORD
[ INVALID KEY imperative-statement ] END-DELETE
CLOSE file-name ...
NOTE: For Sequenced processing of the KSDS define the Select statement with ACCESS MODE IS SEQUENTIAL. For Random processing define the Select statement with ACCESS MODE IS RANDOM. To use both access methods use DYNAMIC as the Access Mode.
The RECORD KEY and the ALTERNATE RECORD KEY needs to be the field within the Record description following the FD entry.
In the ASSIGN Clause you specify the file's system name - the name you use in the JCL.
Use the FILE STATUS instead of AT END clause and INVALID KEY, for better readability. The different File status codes received during the processing of KSDS using the Base cluster are 00, 10, 21(seq error), 22(dupkey), 23(rec not fnd), 24(no space). For records with Alternate Key with Duplicates till existing we receive '02' FS code.
START command is used to start sequential processing from a required position of the file. Not used with RANDOM processing. Move the required value in the Key field and then READ the file using it, during the Random processing.
The WRITE statement is used to add records to the dataset, For the first use the (new file) the KSDS is to be Opened in OUTPUT mode file creation and then latter on as I-O mode for file record additions.
REWRITE command is used to overwrite or update the Last read record, while the file is Opened in I-O mode only.
DELETE statement physically deletes the record read by the last READ statement from a VSAM opened in I-O mode.
The OPEN and CLOSE statements are used to open the file, specified in the required mode of operation and close them.
During RANDOM processing all the commands READ, WRITE, REWRITE, DELETE depends on RECORD KEY. The READ statement for sequential access needs NEXT RECORD option, while for Random access it is not needed.
Environment Division. Input-Output Section. File-Control.
SELECT file-name
ASSIGN TO system-name
ORGNAIZATION IS RELATIVE
[ ACCESS MODE IS SEQUENTIAL / RANDOM / DYNAMIC]
[RELATIVE KEY IS data-name-1]
[ FILE STATUS IS data-name-2 [vsam-code]]
Data Division. File Section.
FD file-name
LABEL RECORDS ARE STANDARD
[ RECORD CONTAINS integer CHARACTERS ]
01 File-Record-Layout PIC ...
Procedure Division.
OPEN { INPUT / OUTPUT / I-O } File-name ...
START file-name [KEY IS { = / > / >= / EQUAL TO / GREATER THAN / NOT LESS THAN...} data-name]
[ INVALID KEY imperative-statement ] [NOT INVALID KEY imperative-statement] END-START
READ file-name [ NEXT ] RECORD
[ INTO identifier ]
[ AT END imperative-statement ] [NOT AT END imperative-statement] END-READ
WRITE record-name
[ FROM identifer ]
[ INVALID KEY imperative-statement ] [NOT INVALID KEY imperative-statement] END-WRITE
REWRITE record-name
[ FROM identifer ]
[ INVALID KEY imperative-statement ] END-REWRITE
DELETE file-name RECORD
[ INVALID KEY imperative-statement ] END-DELETE
CLOSE file-name ...
NOTE: For Sequenced processing of the RRDS define the Select statement with ACCESS MODE IS SEQUENTIAL, and the RELATIVE KEY clause is not needed if the file is being processed sequentially only from the beginning. For Random processing define the Select statement with ACCESS MODE IS RANDOM, and the RELATIVE KEY clause is to be specified. To use both access methods use DYNAMIC as the Access Mode.
In the ASSIGN Clause you specify the file's system name - the name you use in the JCL.
Use the FILE STATUS instead of AT END clause and INVALID KEY, for better readability. The different File status codes received during the processing of KSDS using the Base cluster are 00, 10, 14(RRN size is larger than Relative key filed), 22(invalid key, duplicate key), 23(invalid key. record not found).
START command is used to start sequential processing from a required position of the file. Not used with RANDOM processing. Move the required value in relative key field and then READ the file, during the Random processing.
The WRITE statement is used to add records to the dataset, For the first use the (new file) the RRDS is to be Opened in OUTPUT mode file creation and then latter on as I-O mode for file record additions.
REWRITE command is used to overwrite or update the Last read record, while the file is Opened in I-O mode only.
DELETE statement physically deletes the record read by the last READ statement from a VSAM opened in I-O mode.
The OPEN and CLOSE statements are used to open the file, specified in the required mode of operation and close them.
The processing of an ESDS file is similar to the sequential processing of Non-VSAM file, and the coding logic for ESDS processing is similar to the KSDS sequential processing. The COBOL instructions are:
Environment Division. Input-Output Section. File-Control.
SELECT file-name
ASSIGN TO system-name
ORGNAIZATION IS SEQUENTIAL
[ACCESS MODE IS SEQUENTIAL]
[ FILE STATUS IS data-name-2 [vsam-code]]
Data Division. File Section.
FD file-name
LABEL RECORDS ARE STANDARD
[ RECORD CONTAINS integer CHARACTERS ]
01 File-Record-Layout PIC ...
Procedure Division.
OPEN { INPUT / OUTPUT / I-O / EXTEND} File-name ...
READ file-name [ NEXT ] RECORD
[ INTO data-name ]
[ AT END imperative-statement ] [NOT AT END imperative-statement] END-READ
WRITE record-name
[ FROM identifer ]
[ INVALID KEY imperative-statement ] END-WRITE
REWRITE record-name
[ FROM identifer ]
[ INVALID KEY imperative-statement ] END-REWRITE
CLOSE file-name ...
The BLOCK CONTAINS clause of the Select statement is not needed, though it is needed for Non-VSAM files. To add additional records to the ESDS it needs to be opened in the EXTEND mode with the WRITE command.
The file status codes of an ESDS are similar to that of other VSAM files.
Ex.1. //ddname DD DSNAME=data-set-name,DISP=(SHR/OLD)
//ddname1 DD DUMMY,AMP=AMORG
The format of the DD statements for all the three type of VSAM files are identical as above Ex.1. DSNAME parameter is used to specify the dataset , when it was defined by AMS. DUMMY parameter let's you create a temporary file, which gives EOF when Read and all the Writes are neglected. The AMP=AMORG indicate the dummy file being accessed is a VSAM, As the system tries to read the catalog for VSAM files and DUMMY has no catalog entry, so that the system does not check the catalog. The DISP parameter indicates the disposition of the DS, whether it can be SHaRed by multiple jobs at the same time or a OLD existing one, or NEW dataset.
You need to code the DD statement for every VSAM file. If it has an alternate Index, then code a DD statement for every alternate key (Alternate path dataset) specified in the program. To form the ddname use the assignment name followed by a number. For Example for if EMPMAST is used for employee data file, use EMPMAST1 for alt path.
Under MVS the higher level qualifier (the 1st group of character's in dataset name) indicates the user catalog that owns the file or an alias to it. Although uncommon, you may need to override the user catalog indicated by the high-level qualifier. U can do this by coding the JOBCAT DD statement before the first job step or STEPCAT DD statement to identify a user catalog to be used for the next single job step. If STEPCAT or JOBCAT are specified in the JCL, MVS will search for the dataset in the catalog mentioned in DD statement, if not found, it looks for the file in the user catalog based on the high level qualifier. Note that all VSAM files are to be cataloged.
Under the DOS/VSE environment, the JCL consists of DLBL statement with CAT operand to identify the catalog, for identifying the datasets to be used while executing the program specified in it.
EX. //DLBL ddname,'data.set.name', ,VSAM. If it's used to define a catalog add CAT=<catalogname> at the end of the DLBL statement.
AMS is the general purpose utility used with it's various commands to provide a variety of services for VSAM files. The AMS commands used for VSAM files used in COBOL Programming are.: ALTER - to change the information specified for a catalog, alternate index, or a path at the define time. BLDINDEX - Build an alternate index. DEFINE ALTERNATEINDEX - to define an alternate index. DEFINE CLUSTER - to define a VSAM file (whether it is a KSDS or ESDS or RRDS). DEFINE PATH - Define the path that relates the alternate index to the Base cluster. DELETE - Remove the catalog entry for a catalog, cluster, alternate index or a path. LISTCAT - lists information about a datasets. PRINT - print the contents of VSAM/Non-Vsam files. REPRO -Copy from one file to another (VSAM/Non).
One code AMS commands anywhere in columns 2 through 72. Make sure you will not start the command from col-1. Each AMS command follows the standard format of verb parameters where verb is one of the AMS commands and parameters are used to pass additional information. AMS requires the use of hyphens '-' at the end of line, for multiple parameters to indicate a continuation in the command. Group all the sub-parameters by braces separated by ',' OR ' '.
Code the JOB statement, then the EXEC statement to execute the IDCAMS program, then the datasets to be used, and finally by SYSIN DD * statement that identifies (the file containing /or) the input AMS commands. When you code AMS commands in the job stream instead of a file end them with end of data statement (' /*'). AMS commands can also be executed through TSO from ready prompt, or even using the ICCF on a VSE system.
DEFINE CLUSTER command is used to define a VSAM file. Run the DEFINE USERCATALOG and DEFINE SPACE commands before, to set up the required catalog and space that you need for the file. However, if catalog name is not specified through the DEFINE CLUSTER command, the system automatically uses the catalog based on the high level qualifier of the dataset name being defined. A Define CLUSTER command with most widely used parameters is:
DEFINE CLUSTER (NAME(entry-name)
[OWNER(owner-id)]
[NONINDEXED | INDEXED | NUMBERED ]
[RECORD SIZE(avg max)]
[SPANNED | NONSPANNED]
[KEYS(Length Offset)]
VOLUMES(volser ...)
{CYLINDERS | TRACKS | BLOCKS |RECORDS} (primary [secondary])
[UNIQUE | SUBALLOCATION]
[FREESPACE(ci ca)]
[IMBED]
[SHAREOPTIONS(options)]
[MODEL(entry-name)]
[DATA ( [NAME(entry-name) ]
[VOLUMES(volser ...)]
[{CYLINDERS | TRACKS | BLOCKS |RECORDS} (primary [secondary]) ]
[CONTROLINTERVALSIZE(bytes) ] ) ]
[INDEX ( [NAME(entry-name) ]
[VOLUMES(volser ...)]
[{CYLINDERS | TRACKS | BLOCKS |RECORDS} (primary [secondary]) ] ) ]
[CATALOG(name) ]
Note: that most of the parameters are optional (the one in between the [ and ]) (the underlined sub parm's are defaults).
You might have noticed that only the NAME parameter is needed to be populated for DEFINE CLUSTER command. You can also define the DATA , INDEX component and CATALOG along with the DEFINE CLUSTER at same time. NAME is used to specify the name of the Cluster (datast or file), DATA component, INDEX component of the file.
The KEYS parameter is used to specify the length and offset value of primary Key for KSDS. VOLUMES is an important parameter to be specified the volumes that will contain the cluster or component. NONSPANNED parameter indicates that the logical records can not span through Control Intervals. The default RECORDSIZE is (4089 4089) for non-spanned records and (4086 32600) for spanned records. SUBALLOCATION specifies that the file shares space with other files (does not use it's own data space). IMBED parameter specifies to move the sequence records from index storage area to the first track of the data storage area. Also duplicate records as many times as possible on that track. SHAREOPTIONS with option '1' indicate that the file can be read by multiple jobs at a time but can not be updated. '2' indicate that file is processed by multiple jobs as long as only one job opens the file for output. Use '3' for multiple jobs to process I/O 's at the same time. Use option '3' for files processed by using CICS. MODEL can be used to specify an existing cluster, which can be used as a model. NONINDEXED | INDEXED | NUMBERED defines the record type (ESDS | KSDS | RRDS). Owner defines the owner of the dataset. Cylinder |Tracks |Blocks parameter is used to specify the space to be used by the cluster or component. FREESPACE is used to indicate the amount of free space to be allocated in each CI and also CA. ContolIntervalSize is used to specify the size if needed to different form 4K. IMBED, CI size and Free Space plays a vital role in Performance of the system during the usage of the dataset.
The DEFINE AIX command is coded similar to the DEFINE CLUSTER command as above with a few differences.
DEFINE ALTERNATE INDEX ( NAME (entry-name)
RELATE (entry-name)
[OWNER(owner-name)]
[KEYS(length offset) ]
[ { UNIQUEKEY | NONUNIQUEKEY } ]
[ { UPGRADE | NOUPGRADE } ]
VOLUMES(vol-ser ... ... ...)
...
... /* 6 options Similar to DEFINE CLUSTER, from here. ... /* Data , Index and Catalog components are also same.
NAME(entryname) parameter specifies the name of the alternate index. RELATE specifies the name of the base cluster to which this alternate index is related to. So these two parameters are compulsory along with Volumes, Space (cyl,...). If you want VSAM file to upgrade the Alternate index every time the base cluster is updated use UPGRADE option. UNIQUEKEY specifies that the alternate index key fields are to be unique. Rest of the parameters are same as Cluster.
When you process the records of the base cluster via the alternate keys stored in alternate index, you do not access the base cluster directly, instead you access them through a catalog entry called path. The format of the AMS command is DEFINE PATH ( NAME (entry-name)
PATHENTRY(entry-name from Define AIX)
[ {UPDATE | NOUPDATE} ]
[CATALOG (name)]
The NAME parameter specifies the name of the path. PATHENTRY specifies the name of alternate index to which this path is related. The third parameter specifies whether the dataset could be updated or not while processing this Path. In general a DEFINE PATH command is issued after the DEFINE AIX command.
The BLDINDEX command is used to build index. The Format of this command is as follows.
BLDINDEX {INFILE(ddname) | INDATASET(dataset-name)}
{OUTFILE(ddname) | OUTDATASET(dataset-name)}
Where ddname 's needs to be specified by using a DD statement. The dataset-name for INDATASET is the Base Cluster name itself, and the dataset-name for OUTDATASET specifies the Alternate Index or Path directly.
The LISTCAT command is used to identify the VSAM files defined in a particular catalog or the characteristics of a particular file are. The format of LISTCAT command is.
LISTCAT [CATALOG(name)]
[ENTRIES(entry_name) | LEVEL(level) ]
[entry-type]
[ NAME | HISTORY | VOLUME | ALLOCATION | ALL ]
Any of the parameters be used, by avoiding the others. CATALOG specifies the name of the catalog whose entries you want to list. ENTRIES specifies the files you want to list, which would be generic such as PWSX.*. LEVEL specifies one or more levels of qualification, It lists any dataset whose name match those levels, ex. LEVEL(PWSX.N6SSAGI). Entry-type specifies the type of entries you want to list, which would be ALTERNATEINDEX, CLUSTER, DATA, INDEX, NONVSAM, PATH and USERCATALOG. NAME parameter specifies that VSAM should list only names and types of the specified entries. HISTORY lists NAME info' plus history info'. VOLUME lists HISTORY plus the volume locations of the specified entries. ALLOCATION specifies to list VOLUME plus detailed extent information. ALL specifies VSAM should list all available catalog information for the specified entries.
Its used change the VSAM file name and other characteristics that were assigned to that file. You can also code many DEFINE parameters with the ALTER command. The Format of Alter command with most frequently used options is .
ALTER entry-name
[CATALOG(name)]
[NEWNAME(entry-name1)]
[ADDVOLUMES(vol-ser ... ... ...)]
[REMOVEVOLUMES(vol-ser ...)]
You can use which ever option you want to alter, The entry-name is the name of the object whose entry U want to alter.
The Delete Command is used to remove entries form the VSAM Catalog. The format of a DELETE command is.
DELETE entry-name
[CATALOG(name)]
[entry-type]
[ PURGE | NOPURGE ]
The entry-name is the name of the object being deleted. The entry-type specifies only which type of file needs to be deleted (AlternateIndex, Cluster, Data, Index, NonVsam, Path and Usercatalog). PURGE means VSAM should delete the object even if its retention period has not expired. NOPURGE means VSAM should delete entries only if their retention periods expired. CATALOG specifies the catalog that owns the entries, if not specified it uses standard search.
Ex. ALTER CUSTOMER.MASTER DELETE
NEWNAME(CUTSMAST.FILE)
The PRINT command is used to print a dataset specified by using the INFILE(ddname) or INDATASET(dataset-name). The other optional parameters are CHARACTER | HEX | DUMP , SKIP(count) | FROMKEY(key) | FROMNUMBER (number) | FROMADDRESS(address) , COUNT(count) | TOKEY(key) | TONUMBER(number) | TOADDRESS(address). The format of the output can be specified, The first record of the file you want to print, and last record of the file to be printed are specified through the PRINT command. COUNT specifies # of records to be printed.
The REPRO command is used to copy the contents of one dataset into another. The options are the same as for PRINT command. In addition the REPRO command needs the OUTFILE | OUTDATASET parameters and REPLACE or NOREPLACE option, to specify what to do if the output dataset already exists in the system.
Ex. of AMS commands to reorganize a VSAM key-sequenced dataset.
DEFINE CLUSTER ( NAME(MMA2.EMPMAST.REPRO) -
MODEL(MMA2.EMPLOYEE.MASTER) -
VOLUME(MOS88V) -
DATA ( NAME(MMA2.EMPMAST.REPRO.DATA) -
CYLINDERS(5 1)
INDEX ( NAME(MMA2.EMPMAST.REPRO.INDEX) )
REPRO INDATASET(MMA2.EMPLOYEE.MASTER) -
OUTDATASET(MMA2.EMPMAST.REPRO)
DELETE MMA2.EMPLOYEE.MASTER
ALTER MMA2.EMPMAST.REPRO -
NEWNAME(MMA2.EMPLOYEE.MASTER)
ALTER MMA2.EMPMAST.REPRO.DATA -
NEWNAME(MMA2.EMPLOYEE.MASTER.DATA
ALTER MMA2.EMPMAST.REPRO.INDEX -
NEWNAME(MMA2.EMPLOYEE.MASTER.INDEX