Using KSAM XL and KSAM 64
> Chapter 2 Creating a KSAM FileCreating the File With the BUILD Command |
||||||||||||||||||||||
|
KSAM File CharacteristicsThe key characteristics, the method of file numbering, and the reuse option are unique to KSAM 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. Key CharacteristicsThe ;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.;KEY=(B,9,5,RDUP;I,17,3,DUP)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.
First Record NumberThe ;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.REUSE OptionKSAM 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.Language IDThe 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.OPTMBLK/DEFBLK OptionUsers can assure efficient disk space utilization by using the OPTMBLK option of the BUILD command. When specified, OPTMBLK allows KSAM to choose the optimal data block size based on the record size of a file. Refer to MPE/iX Commands Reference Manual 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 64 file using the OPTMBLK parameter Figure 2-3 Creating a KSAM XL file with data block size set at 4K bytes (default) Figure 2-4 Creating a KSAM 64 file with data block size set at 4K bytes (default) Use the FILE command along with the FCOPY command to copy a new KSAM 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.Sample BUILD CommandFigure 2-5 "Building the AR Master KSAM XL 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-6 Building the AR Master KSAM64 File
Specifying an Indirect FileTo 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. (N,4,6;& B,10,25,RDUP;& N,65,5,RDUP;& B,70,3,RDUP)Figure 2-7 "Using a Key Data File to Create a KSAM XL File" shows the command for setting up the same accounts receivable master file as in Figure 2-5 "Building the AR Master KSAM XL 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. Figure 2-7 Using a Key Data File to Create a KSAM XL File :BUILD ARMSTRXL.MGR.AR;REC=-80,,F,ASCII;DEV=DISC;& DISC=100;KSAMXL;KEY=^KEYDATA;& FIRSTREC=1;REUSE ;LANG=5Figure 2-8 Using a Key Data File to Create a KSAM 64 File :BUILD ARMSTR64.MGR.AR;REC=-80,,F,ASCII;DEV=DISC;& DISC=100;KSAM64;KEY=^KEYDATA;& FIRSTREC=1;REUSE ;LANG=5
|