|
|
Using KSAM XL: 900 Series HP 3000 Computer Systems > Chapter 2 Creating a KSAM XL FileCreating the File With the BUILD Command |
|
The BUILD command parameters define standard file characteristics, such as the file and record lengths, and file, record, and data types. For KSAM XL files, you must also specify characteristics of each key field and special KSAM options. The following list offers the most common file characteristics that you need to decide before building a KSAM XL file.
The key characteristics, the method of file numbering, and the reuse option are unique to KSAM XL files. Each key must be defined in the BUILD command's ;KEY= parameter. Record numbering and the reuse option must be specified if the default values are not acceptable. The ;KEY= parameter of the BUILD command encloses all key characteristics in parentheses. Individual characteristics for a single key are separated by commas. Each key description is separated from the next by a semicolon. The following example shows a ;KEY= parameter that defines two keys. Four characteristics are defined for each key: key type, location, size, and duplication method.
The following descriptions list the available options for the definition and use of keys. Four characteristics are defined for each key: key type, location,size, and duplication method. The key type defines the data type of the key field. The type is identified by a keyword or its abbreviation. In the previous example, the first key field contains byte data and the second is an integer. The following list provides the valid key types.
The key's location is determined by the position of the first byte of the field in relation to the beginning of the record. The first byte of the record is considered to be 1. Only one key can start at a particular location. In the previous example, the first key begins in byte 9, the second in byte 17. The size of the key must be specified in bytes. Specific use of any key is determined by its definition. The ranges listed below indicate the maximum possible values. The maximum length of the key varies by data type, as specified in the following list:
The duplication key characteristic is an optional field. If a key must be unique, such as an account number or social security number, no additional parameters are made. The default value is no duplication. If the key can be duplicated, there are two methods of inserting duplicate key values in the index's duplicate key chain. DUP specifies that each new duplicate key is inserted at the end of the duplicate key chain, maintaining chronological order. RDUP specifies that each new duplicate key is inserted randomly in the duplicate key chain. RDUP is used if the reuse option is selected. With RDUP, chronological order is not maintained. The ;FIRSTREC= parameter of the BUILD command specifies the number of the first record in the file. Several record retrieval methods use record numbers to identify the physical location of a record. You can specify whether to use "0" or "1" to identify the first record. The default value is 0. KSAM XL files can reuse deleted record space if the REUSE option is specified. This option, however, increases the allocated space reserved for the file by 15 percent and distributes free space evenly throughout the file when the file is initially loaded. When a record is to be added to the file, free space is available so that a search for record space is not lengthy. When a record is deleted, its space is added to the free space available. The NOREUSE option, the default value, does not allow the reuse of deleted record space. This option maintains physical record order. A new record is appended to the end of the file, even if other records have been deleted. If many records are added and deleted, the file continues to expand in size. In such cases, it is recommended that the file be copied regularly to eliminate the unusable space if disk space is needed. The optional ;LANG= parameter of the BUILD command 224 specifies the native language specifies the native language of the data in the file. You can select the language by entering a code of up to three digits or by entering the language name. To find out what languages can be accessed on your system, enter RUN NLUTIL.PUB.SYS. Any of the listed language IDs can be entered in this field. The default language is Native-3000. Different affectd languages may cause the sequential ordering of records to be affected. Users can assure efficient disk space utilization by using the OPTMBLK option of the BUILD command. When specified, OPTMBLK allows KSAM XL to choose the optimal data block size based on the record size of a file. Refer to MPE/iX Commands Reference Manual Volumes 1 and 2 (32650-90003 and 32650-90364) for more information on using this option. The LISTFILE, 7 command displays the optimal data block size and the 8 bit value of the flagword of the KSAM parameter. Figure 2-1 Creating a KSAM XL file using the OPTMBLK parameter
The DEFBLK parameter of the BUILD command allows the user to select a data block size of 4K bytes. If neither OPTMBLK nor DEFBLK is specified, the data block size defaults to DEFBLK (block size of 4K bytes). Figure 2-2 Creating a KSAM XL file with the data block size set at 4K bytes (default)
Use the FILE command along with the FCOPY command to copy a new KSAM XL file to one where the data block size is chosen using OPTMBLK. Users with existing KSAM XL files of 4K bytes can convert their files by using FCOPY. Specify the OPTMBLK option in the file equation. This allows KSAM XL to select the data block size in the file equation. If a file equation does not specify either option, FCOPY uses the FROM= file's setting of OPTMBLK or DEFBLK. Figure 2-3 “Building the AR Master File” builds a sample KSAM XL master file to process 80-byte accounts receivable records in English. The maximum size of the file is 100 records. Record numbering in the sample file begins with number 1. Reuse of deleted record space is allowed. In this sample, four key fields are defined to sequence data for various programming functions:
Figure 2-3 “Building the AR Master File” creates the ARMSTR file with the preceding specifications using the BUILD command. (Note that ampersands have been included at the end of each line to continue the command on subsequent lines to improve readability.) Figure 2-3 Building the AR Master File
To reduce errors, the characteristics for key data fields can be contained in an indirect file and referred to in the BUILD command. Such a file can be created using an editor, such as HP EDIT. The information is structured as it would be if it were included in the command. The format of the key data in the indirect file is shown in the following example.
Figure 2-4 “Using a Key Data File” shows the command for setting up the same accounts receivable master file as in Figure 2-3 “Building the AR Master File”. The KEY= parameter, however, refers to the indirect file named KEYDATA for the key data specifications. The character ^ specifies that an indirect file contains the data. |
|