The HPFOPEN and FOPEN intrinsics can be used within a program to create
and open a KSAM file in a single step. As with the BUILD command, file and key characteristics are provided
as parameter data.
 |
 |  |
 |
 | NOTE: The HPFOPEN intrinsic can be used only in an MPE/iX environment.
If a program is to be developed for both MPE/iX and MPE V/E systems,
the FOPEN intrinsic should be used. Refer to “Mixed Mode Operation” in Chapter 8 for information regarding cross development. |
 |
 |  |
 |
The unique KSAM file and key characteristics are contained
in an array that varies in length from 40 to 162 words. The format
of the array is shown in Figure 2-9 “KSAM Parameter Format”. Characteristics
for a maximum of sixteen keys need to be specified in the array.
Standard file characteristics are contained in the file options
parameter of the intrinsic.
Language ID |
 |
Enter the three digit code for the native language that you
desire. To find out what languages can be accessed on your system,
enter RUN NLUTIL.PUB.SYS. A list of languages and their IDs is displayed
on the screen. Any of the listed language IDs can be entered in this
field.
Flag word |
 |
The flag word contains two bytes defining the KSAM file characteristics:
- Bits
Value/Meaning
- 15:1
Reserved.
- 14:1
Enter a 1 if record numbering is to start with 1.
Enter 0 if record numbering is to start with 0.
- 13:1
Enter 1 if only sequential writing by primary key
is allowed.
Enter 0 if random writing by primary key is allowed.
- 12:1
Enter 1 if deleted record space can be reused.
Enter 0 if deleted record space cannot be used.
- 11:1
Enter 1 if a language type is specified.
Enter 0 if a language type is not specified.
- 10:1
Enter 1 if the primary key cannot be changed with
the FUPDATE intrinsic for files that are opened for sequential
processing.
Enter 0 if the primary key can be changed with the FUPDATE intrinsic for files that are opened for sequential
processing.
- 9:1
Enter 1 if the file is programmatically accessed
by the COBOL programming language. Enter 0 if the file is not programmatically accessed
by the COBOL programming language. This enables KSAM to process
COBOL information according to COBOL standards.
- 8:1
Enter 1 if KSAM is to select the optimal data block
size. Enter 0 if KSAM is to use the default data block size.
- 0:9
Enter 0. These bits are reserved and must contain
zeros.
Number of Keys |
 |
Enter a digit between 1 and 16 in word 16 to specify the number
of keys to be defined for this file. Refer to Figure 2-9 “KSAM Parameter Format” for
the location of this field.
Key Parameters |
 |
The following parameters are defined for each key. The information
about each key is similar to the BUILD command's KEY= parameter.
- key type
Enter one of the following codes specifying the
type of data the key will contain.
- Code
Key Data Type
- 1
Byte key (1 to 255 bytes)
- 2
Short integer key (255 bytes)
- 3
Integer key (255 bytes)
- 4
Real number key (255 bytes)
- 5
Long real number key (255 bytes)
- 6
Numeric display key (1 to 28 bytes)
- 7
Packed decimal key, odd number of digits (1 to 14
bytes)
- 8
Packed decimal key, even number of digits (2 to
14 bytes)
- 9
IEEE floating-point decimal key (4, 8, or 16 bytes)
- key length
Enter the length of the key in bytes. A maximum
of 255 bytes is allowed, but the length is dependent on the type
of key data specified.
- key location
Enter the relative location in bytes of the key
field in the record. Note that the first byte of the record is considered
1.
- duplicate key flag
Enter 1 if duplicate key values are allowed for
this key.
Enter 0 if duplicate key values are not allowed for
this key.
- random insert flag
This field specifies the method of inserting duplicate
key values. To use this feature, the previous duplicate key flag must
be set to 1.
Enter 0 if duplicate key values are to be inserted
at the end of the duplicate key chain.
Enter 1 if the duplicate key values are to be inserted randomly
in the duplicate key chain.
Figure 2-10 “KSAM Parameter Settings” provides an example of the declarations
that are needed to define and load a KSAM XL parameter array using
Pascal/iX. Chapter 4 “Opening and Closing the File” provides an example of an
HPFOPEN intrinsic call that creates and opens a KSAM file.
The HPFOPEN intrinsic uses item number pairs to identify intrinsic
parameters. Item number 54 is paired with the KSAM parameter array
to define the KSAM XL key structure. Other item number pairs that
relate to KSAM XL files specifically are listed below:
- 10
This item number identifies the KSAM XL file type.
Enter 3 to indicate that a KSAM XL file is to be created.
Enter 7 to indicate that a KSAM64 file is to be created.
- 17
A KSAM XL file can be accessed only as its own type.
Enter 0 for a KSAM XL file.
The FOPEN intrinsic can also be used to create and open
a KSAM file. The same KSAM parameter array is used as an FOPEN parameter option. The FOPEN intrinsic uses parameter values rather than item
number pairs to identify file characteristics and the KSAM key value
array. Refer to Chapter 4 “Opening and Closing the File” for a description of
the FOPEN intrinsic.