HP RPG/XL Programmer's Guide (30318-90001)

3-: 2
* No automatic maintenance of data relationships
* Extra memory usage when several users access the same file
simultaneously
Creating a KSAM Disc File
There are three ways to create a KSAM disc file:
Use this method: When:
KSAMUTIL You want to build an empty KSAM file or when
you cannot use an RPG program to build it (RPG
programs won't let you specify more than one
key field, for instance).
(KSAMUTIL is a KSAM utility that creates an
empty KSAM file.)
FCOPY You want to create an empty KSAM file or when
you want to copy all or part of a KSAM or MPE
file to an existing KSAM file.
(FCOPY is a general-purpose system command that
creates and copies files.)
RPG program You want to create a new KSAM file and load it
with data at the same time.
When you create a KSAM file, you specify the record keys (key fields)
that it contains. The first key that you enter is called the
primary
key. The second and successive keys that you enter are called
secondary
keys. Secondary keys are independent of primary keys; they are not
subordinate to them. Secondary keys can be thought of as alternate keys.
Both primary and secondary keys are maintained in the same KSAM key file.
Creating KSAM files using KSAMUTIL, FCOPY and RPG programs are discussed
in the next three sections.
Creating a KSAM File Using KSAMUTIL. The most flexible method of
creating a KSAM file is to use KSAMUTIL. You define the file size and key
fields using this utility. KSAMUTIL creates an empty file. It does not
load the file with actual data. (Use FCOPY or an RPG program to load
data into a file created by KSAMUTIL.)
The following steps tell you how to create a KSAM file using KSAMUTIL.
For detailed information about KSAMUTIL commands, see the
KSAM/3000
Reference Manual
.
Follow these steps to create a KSAM file using KSAMUTIL:
1. Enter the following command at the operating system colon prompt
(:),
RUN KSAMUTIL.PUB.SYS
You see the prompt, >. KSAMUTIL is prompting you to enter
information about the KSAM file.
2. Enter a KSAMUTIL BUILD command to create the KSAM file.
For example, the following command creates a file MASTFL having
256 characters per record. Its key file is MASTFLK. Its primary
key is a 5-byte field (KEY=B) starting in position 1 of the
record:
>BUILD MASTFL;REC=-256,1,F,ASCII;KEYFILE=MASTFLK;KEY=B,1,5
3. End KSAMUTIL by typing,
EXIT
Creating a KSAM File Using FCOPY. Use FCOPY when you want to create an
empty KSAM file or when you want to copy all or part of a KSAM or MPE
file to an existing KSAM file.
To use FCOPY, enter an FCOPY command at the operating system prompt.
(For detailed information on the FCOPY command, see the
FCOPY Reference