As discussed in Chapter 2, a file can be created when it is
opened using the HPFOPEN or FOPEN intrinsics. The file characteristics must be specified,
as well as the formal file designator, the domain, and the access
method. The most common item numbers used to create and open KSAM
files with the HPFOPEN intrinsic include:
- 2
The file designator.
- 10
A file type of 3 for KSAM XL files. A file type
of 7 for KSAM64 files.
- 11
An access option of 1 for writing records to a new
file.
- 19
The record length.
- 35
The maximum file length.
- 50
Either a disposition of 2 for a temporary file or
1 for a permanent file.
- 53
ASCII or binary record data.
- 54
The KSAM key parameter defining primary and alternate
key descriptions.
Figure 4-2 “Opening a New KSAM File with HPFOPEN” presents a portion of a program that
builds and opens a KSAM file.
To create a new KSAM64 file set ksam_type=7 in the program
segment shown in To
create a new KSAM file using the FOPEN intrinsic, file characteristics and KSAM key information
are specified in the positional parameters. In most cases, the
foption, aoption, recsize, ksamparam, and filesize parameters must be specified. Commas identify those
positional parameters for which the default specifications are used. Figure 4-3 “Opening a New KSAM XL File with FOPEN” provides an FOPEN intrinsic call that creates a KSAM XL file with
write access to build the file.