Records in database files can be described in two ways:
- Field level description. The fields in the record are described to
the system. Some of the things you can describe for each field
include: name, length, data type, validity checks, and text
description. Database files that are created with field level
descriptions are referred to as externally described files.
- Record level description. Only the length of the record in the file
is described to the system. The system does not know about
fields in the file. These database files are referred to as
program-described files.
Regardless of whether a file is described to the field or record level, you
must describe and create the file before you can compile a program that uses
that file. That is, the file must exist on the system before you use
it.
Programs can use file descriptions in two ways:
- The program uses the field-level descriptions that are part of the
file. Because the field descriptions are external to the program
itself, the term, externally described data, is used.
- The program uses fields that are described in the program itself;
therefore, the data is called program-described data. Fields in files
that are only described to the record level must be described in the program
using the file.
Programs can use either externally described or program-described
files. However, if you choose to describe a file to the field level,
the system can do more for you. For example, when you compile your
programs, the system can extract information from an externally described file
and automatically include field information in your programs.
Therefore, you do not have to code the field information in each program that
uses the file.
The following figure shows the typical relationships between files and
programs on the AS/400 system:

- (1)
- The program uses the field level description of a file that is defined to
the system. At compilation time, the language compiler copies the
external description of the file into the program.
- (2)
- The program uses a file that is described to the field level to the
system, but it does not use the actual field descriptions. At
compilation time, the language compiler does not copy the external description
of the file into the program. The fields in the file are described in
the program. In this case, the field attributes (for example, field
length) used in the program must be the same as the field attributes in the
external description.
- (3)
- The program uses a file that is described only to the record level to the
system. The fields in the file must be described in the program.
Externally described files can also be described in a program. You
might want to use this method for compatibility with previous systems.
For example, you want to run programs on the AS/400 system that originally
came from a traditional file system. Those programs use
program-described data, and the file itself is only described to the record
level. At a later time, you describe the file to the field level
(externally described file) to use more of the database functions available on
the system. Your old programs, containing program-described data, can
continue to use the externally described file while new programs use the
field-level descriptions that are part of the file. Over time, you can
change one or more of your old programs to use the field level
descriptions.
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]