C H A P T E R 5 |
Analyzing VSAM Files |
You might need to analyze VSAM file contents to determine whether the contents are valid. You can use the Sun MTP kixvalfle utility to assist in the analysis. kixvalfle analyzes the physical block relationships and reports possible problems.
This chapter includes the following topics:
It also explains how to locate records in VSAM datasets. Refer to the Sun Mainframe Transaction Processing Software Administrator's Guide for more information about file integrity.
This section describes how to determine if a dataset is corrupted, how to salvage a corrupted dataset, and how to load a salvaged dataset.
|
1. Shut down the region or close the suspected dataset for access.
2. Execute the kixvalfle -i command on the suspected dataset.
You should redirect the output to a file, which you can send to your authorized service provider for further analysis. For example:
3. If the output reports a missing block, or if it does not indicate "no errors," you might have to salvage the dataset.
|
1. Shut down the region or close the corrupted dataset for access.
2. Execute the kixsalvage command on the corrupted dataset.
You can use the -c option to create a file in mfrcdv format that can be sorted by a COBOL sort utility, or the -2 option to create a file in recordv format that you can sort with another sort utility. For example:
3. Use a sort utility to sort the salvaged data.
The definition of the dataset, the record length, and the key attributes are required.
|
Make sure that you have read and write permissions to the dataset.
2. Perform one of the following tasks:
a. Use a text editor to create a batch shell script that contains these commands:
kixfile -lY dataset unikixbld -i -d dataset unikixbld -tv -d dataset -s salvagedfile -r recordformat kixfile -lN dataset |
The name of the salvaged file and the record format must match the values you specified when you executed the kixsalvage command.
3. Load the sorted salvaged file into the dataset using unikixbld or a JCL IDCAMS REPRO procedure.
Every VSAM file in Sun MTP uses the block structure shown in TABLE 5-1.
ESDS files store their records in sequential order. In this type of file, you can calculate the physical position of a record from the record identification (RIDFLD) field.
|
1. Determine the block number by dividing the RIDFLD by the VSAM block size minus 20 and adding 1.
2. Locate the record header by taking the result from Step 1 and adding the block header length (20).
3. Locate the record data by adding the length of the record header (4).
|
1. Calculate the record number relative to zero by dividing RIDFLD by the record length.
2. Calculate the number of records that can fit on a block by adding the record size plus the record header size and dividing by the space available on each block (4076, 8172, 16364, or 32748).
3. Calculate the block number by dividing the record number by the number of records on a block and adding one.
The result gives the record number on the block.
4. Locate the record header in the data area by multiplying the record number on the block by the record size and the record header size (4).
5. Locate the record header in the block by adding the block header length (20).
You can read an ESDS file using the Record Editor or view it with kixview. Refer to the Sun Mainframe Transaction Processing Software Administrator's Guide for information about the Record Editor and to the Sun Mainframe Transaction Processing Software Reference Guide for information about kixview.
RRDS files also store their records in sequential order. In this type of file, you can calculate the physical position of a record from the RIDFLD. The record number can be converted into a byte position by calculating the number of records that can fit on a block, determining which block should contain the record, and then calculating the record location inside of that block.
The VSAM block size can be 4, 8, 16, or 32 Kbytes. The following procedure uses the default 4-Kbyte block size, a record size of 80, and a RIDFLD of 410.
1. The number of records per block is equal to the VSAM block size minus 20 bytes (4076) divided by 80 bytes per record, plus a 4-byte record header.
This equals 48 records per block with 44 bytes unused at the end of each block.
2. The block number is equal to the RIDFLD of 410 minus 1 (because RRDS RIDFLDs are relative to 1), divided by 48 records per block plus 1 (block numbers are also relative to 1).
This results in a block number of 9.
Therefore, the ninth block starts at byte 32768 in the file (relative to zero).
4. To calculate the offset in a block, determine the record number in a block.
This is equal to the RIDFLD minus 1 (since it is relative to 1), minus the total of the records per block, times the block number (410 - 1 - (48 * (9-1))) for a record number of 25. The offset in the block is then equal to the block header size, plus the total of the block record number, times the record number on the block, plus the record header size (20 + (25*84) + 4), for an offset in the block of 2124.
5. The byte offset in the file is the offset in the file to the start of the block (32768), plus the offset in the block (2124) for a byte location in the file of 34892.
You can read an RRDS file using the Record Editor or view it with kixview. Refer to the Sun Mainframe Transaction Processing Software Administrator's Guide for information about the Record Editor and to the Sun Mainframe Transaction Processing Software Reference Guide for information about kixview.
KSDS files and alternate index files each have a data file and an index file.
You can read a KSDS file using the Record Editor or view it with kixview. Refer to the Sun Mainframe Transaction Processing Software Administrator's Guide for information about the Record Editor and to the Sun Mainframe Transaction Processing Software Reference Guide for information about kixview.
Each data record in Sun MTP files has the format shown in TABLE 5-2. This format is used for KSDS, ESDS, and RRDS files. Each record's data is preceded by a 4-byte record header. When the record is greater than the VSAM block size minus 24 bytes, the record is spanned; each segment of the spanned record has a 4-byte header. When spanned records are present, they always start at the beginning of the data portion of a block. Each segment of a spanned record uses the entire data portion of a block except for the last segment. The remaining space on the block is always unused.
Note - KSDS alternate index data files and KSDS index files do not use this spanned record format. |
Index files in Sun MTP contain entries that point to other index entries or to data blocks depending upon the number of index levels. You can determine where a specific index entry points from the block type field of the block header.
The format of index entries is shown in TABLE 5-3.
Copyright © 2004, Sun Microsystems, Inc. All rights reserved.