Defining Externally Described Files
field in positions 49 through 62 and assign a match-level value in posi-
tions 65 and 66.
In this example, the CUSTNO field in both records MSTREC and
WKREC is assigned the match-level value M1.
2 To assign a field indicator to a field in an externally described record,
specify the record-format name in positions 7 through 16 of the record-
identification line. On the field-description line, specify the field name in
positions 49 through 62, and specify an indicator in positions 69 through
74.
In this example, the field BALDUE in the record WKREC is tested for
zero when it is read into the program. If the field’s value is zero, indi-
cator 98 is set on.
Using Output Specifications
Output specifications are optional for an externally described file. RPG supports file
operation codes such as WRITE and UPDATE that use the external record-format
description to describe the output record without requiring output specifications for
the externally described file.
You can use output specification to control when the data is to be written, or to
specify selective fields that are to be written. The valid entries for the field-
description line for an externally described file are output indicators (positions 21 -
29), field name (positions 30 - 43), and blank after (position 45). Edit words and
edit codes for fields written to an externally described file are specified in the DDS
for the file. Device-dependent functions such as fetch overflow (position 18) or
space/skip (positions 40 - 51) are not valid in an RPG program for externally
described files. The overflow indicator is not valid for externally described files
either. For a description of how to specify editing in the DDS, see the
DDS Refer-
ence
.
If output specifications are used for an externally described file, the record-format
name is specified in positions 7 - 16 instead of the file name.
If all the fields in an externally described file are to be placed in the output record,
enter *ALL in positions 30 through 43 of the field-description line. If *ALL is speci-
fied, you cannot specify other field description lines for that record.
If you want to place only certain fields in the output record, enter the field name in
positions 30 through 43. The field names you specify in these positions must be the
field names defined in the external record description, unless the field was renamed
on the input specifications. See Figure 135 on page 270.
You should know about these considerations for using the output specifications for
an externally described file:
In the output of an update record, only those fields specified in the output field
specifications and meeting the conditions specified by the output indicators are
placed in the output record to be rewritten. Fields not specified in the output
specifications are rewritten using the values that were read. This technique
offers a good method of control as opposed to the UPDATE operation code
that updates all fields.
Chapter 14. Defining Files 269