The File Extension Specification Fields [ HP RPG/iX Reference Manual ] MPE/iX 5.0 Documentation
HP RPG/iX Reference Manual
The File Extension Specification Fields
The fields you can use in the File Extension Specification are described
in the sections which follow in this chapter. Each field has a unique
name and occupies specific positions (columns) in the specification.
Sequence Number (Columns 1-5)
The Sequence Number Field contains the source record sequence number,
described in Chapter 2.
Specification Type (Column 6)
This field contains an E to identify this line as a File Extension
Specification.
Chaining File Record Sequence (Columns 7-8)
This field gives the record sequence of the file and is used only with
chaining files. (See the next field, Chaining Code Identifier (columns
9-10), and the Matching/Chaining Fields (columns 61-62) in the Input
Specification for information on chaining files.) This field is not
checked by HP RPG; it is available for compatibility with other
implementations of RPG.
Enter the same value in the Group Sequence Field (columns 15-16) of the
Input Specification.
--------------------------------------------------------------------------------------------
| | |
| Columns 7-8 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| Two digits (00-99) | The same record sequence specified for the chaining file in the |
| or two letters (A-Z) | Input Specifications. |
| | |
| blank | None. |
| | |
--------------------------------------------------------------------------------------------
Example
Figure 5-2 shows how to assign the sequence number 01 to all records
in the file ACCTS. A 01 is entered in this field and also in the Group
Sequence Field (columns 15-16) of the Input Specification.
___________________________________________________________________________________
| |
| 1 2 3 4 5 6 7 |
| 678901234567890123456789012345678901234567890123456789012345678901234|
| _______________________________________________________ |
| |
| E01C1ACCTS DISKA CHAINED FILE |
| . |
| . |
| . |
| |
| IACCTS 01 I 50CODE C1 |
| |
| |
___________________________________________________________________________________
Figure 5-2. Entering a Chaining File Record Sequence Number
Chaining Code Identifier (Columns 9-10)
This field identifies the chaining field used for chaining. Use this
field only for chaining files.
--------------------------------------------------------------------------------------------
| | |
| Columns 9-10 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| C1-C9 | The chaining field code that identifies the chaining field in |
| | the Matching/Chaining Field of the Input Specification. |
| | |
| blank | The file is not a chaining file. |
| | |
--------------------------------------------------------------------------------------------
A chaining field is a field containing a record number or key that points
to a related record in another file. For instance, a customer
transaction file can contain a chaining field that points to customer
addresses in an address file. Once customer addresses are accessed,
mailing labels can be printed.
You can enter up to nine chaining fields or field combinations in a
chaining file. Associate each chaining code to a field on an Input
Specification using the Matching/Chaining Fields (columns 61-62) of the
Input Specification. You can assign the same chaining code to more than
one field.
This field is required if you use a chaining field code in an Input
Specification. You can use the same chaining field code in more than one
File Extension Specification if the associated files access the same
chained file. The From File Names associated with the chaining field
code must be different in each instance, but the To File Names must be
the same. (The From File Name and the To File Name Fields are described
in the next two sections.)
Example
Figure 5-2 shows how to assign the Chaining Code Identifier C1 to the
field named CODE in the file ACCTS. This is done by:
1. Entering C1 in the Chaining Code Identifier Field of the File
Extension Specification.
2. Entering C1 in the Matching/Chaining Fields (columns 61-62) of the
Input Specification, next to the field CODE.
From File Name (Columns 11-18)
This field contains the name of a chaining file, preexecution-time table
or array, or a Record Address File.
--------------------------------------------------------------------------------------------
| | |
| Columns 11-18 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| Valid file name. (File names can | The name of a chaining file defined in an Input |
| contain from one to eight | Specification with a chaining code in the |
| characters, beginning with a | Matching/Chaining Field, |
| letter. The remaining characters | or The name of a Record Address File (RAF) |
| can be letters or digits. | containing relative record numbers or record keys. |
| Embedded blanks are not allowed. | or The name of the file from which a |
| The file name must be defined in | preexecution-time table or array is read. |
| the File Name Field of a File | |
| Description Specification.) | |
| | |
| blank | This is a compile-time table or array if an entry |
| | appears in the Entries Per Record Field (columns |
| | 33-35); it is an execution-time array if no entry |
| | appears in the Entries Per Record Field. |
| | |
--------------------------------------------------------------------------------------------
Table and array files contain groups of related data arranged for
efficient, systematic reference. Tables and arrays can be searched
sequentially and randomly (see the Table/Array Look-Up Field (column 34)
in the Header Specification). When you search a table or array
sequentially, each entry (starting with the first) is read until the
entry is found. When you perform a binary search on a table or array,
entries are accessed directly. You do not pass through other elements
looking for the one you need. For arrays, you can process the entire
array by using only its name.
The types of tables and arrays are:
* Compile-time tables and arrays
These tables and arrays are loaded during compilation and compiled
with the source program. They become a permanent part of the
object program. Compile-time tables and arrays are loaded in the
order in which you enter the File Extension Specifications.
Compile-time tables and arrays may be appended to the end of the
source program or contained in separate disk files. If they
reside in separate disk files, you must name those files using
Array/Table File Name Specifications.
* Preexecution-time tables and arrays
These tables and arrays are loaded from disk by the object program
before the RPG logic cycle begins. When you use more than one
preexecution-time table or array in the same file, they are
read in the order in which you enter their File Extension
Specifications.
* Execution-time arrays
These arrays can reside in separate disk files or you can create
them in the program. If they reside on disk, they are loaded at
execution time the same way input data is loaded. You define them
using Input Specifications. To create them in the program, use
Calculation Specification operations. There are no execution-time
tables in RPG.
For information about creating and loading tables and arrays, see the
last section in this chapter titled "Tables and Arrays".
To File Name (Columns 19-26)
This field contains the target file for the chaining file or RAF entered
in the From File Name Field. This field can also contain an output disk
or tape file to which compile-time and preexecution time tables and
arrays are written when the program ends. (Execution-time arrays cannot
be written when the program ends.)
--------------------------------------------------------------------------------------------
| | |
| Columns 19-26 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| Valid file name. (File names can | The name of the chained file processed by the |
| contain from one to eight | chaining file named in the From File Name Field, |
| characters, beginning with a | |
| letter. The remaining characters | or |
| can be letters or digits. | |
| Embedded blanks are not allowed.) | The name of the input or update file processed by |
| | the RAF named in the From File Name Field, |
| | |
| | or |
| | |
| | The name of a sequential output file to which the |
| | compile-time or preexecution-time table or array |
| | named in the Table/Array Name Field (columns 27-32) |
| | is written when the program ends. |
| | |
| blank | No file is used. Tables and arrays, if any, are |
| | not copied. |
| | |
--------------------------------------------------------------------------------------------
When you enter an output file for tables and arrays, the tables and
arrays (except those destined for a printer or controlled by Line Counter
Specifications) have the same format as used for input. If you're
writing more one table or array to the file, RPG writes a separator
record after each one. The record has asterisks in positions 1-2 and a
blank in position 3. When you use alternating tables, they are written
as alternating fields. If you write data to the file also, the tables
and arrays immediately follow the data with no separator records.
Tables and arrays destined for the line printer or that are controlled by
Line Counter Specifications, have a unique format and an identifying
header.
You can rearrange table and array output by using an Output
Specification.
The record size for the file you enter in this field must be large enough
to accommodate the number you enter in the Entries Per Record Field
(columns 33-35). If the record size is larger, entries are written until
the record is full.
Table/Array Name (Columns 27-32)
This field names a table or array used in the program.
--------------------------------------------------------------------------------------------
| | |
| Columns 27-32 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| Table or array name. (Table names can contain from | The name of an array or table that |
| three to six characters, beginning with TAB; array | is searched in the program. |
| names can contain from one to six characters, | |
| beginning with a letter or one of the special | |
| characters @, $, or #. For both table and array | |
| names, the remaining characters can be letters, | |
| digits, or @, $, or #. Embedded blanks are not | |
| allowed. | |
| | |
| blank | Tables and arrays are not used. |
| | |
--------------------------------------------------------------------------------------------
The table or array name that you enter in this field is the one that you
use to reference the table or array elsewhere in the program. You can
reference tables in Calculation and Output Specifications and you can
reference arrays in Input, Calculation and Output Specifications.) You
can name any kind of table or array in this field: compile-time,
preexecution-time, or execution-time. Table and array names, however,
must be unique.
The table or array that you enter in this field can have an alternating
table or array associated with it. Define the alternating table or array
in columns 46-57 of this specification.
Entries Per Record (Columns 33-35)
This field contains the number of table or array entries in each input
record of a compile-time or preexecution-time table or array.
--------------------------------------------------------------------------------------------
| | |
| Columns 33-35 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| 1-999 | The number of table/array entries in each table or array input |
| (right-justified, | record. |
| leading zeroes are | |
| not required) | |
| | |
| blank | This is an execution-time array. |
| | |
--------------------------------------------------------------------------------------------
Each record (except the last) in the table or array file, must contain
exactly the number of entries you specify. The last record may contain
fewer entries, but not more.
When you use an alternating table or array, every entry in the table or
array is associated with the same entry in the alternating table or
array. You must format the input records for the tables or arrays in
alternating form. For example, if TABLEB is the alternating table for
TABLEA, entry A1 corresponds to B1, A2 corresponds to B2, and so forth.
TABLEA TABLEB
A1 B1
A2 B2
A3 B3
A4 B4
Each pair of corresponding entries (for example, A1 and B1) must appear
in the same input record in alternating form; you cannot split them
between records. Entries in the alternating pair are treated as one
table entry. Entries in TABLEA and TABLEB are entered on an input record
as shown below:
A1B1A2B2A3B3A4B4
For TABLEA and TABLEB, the number of entries per record is 4.
Entries Per Table/Array (Columns 36-39)
This field contains the maximum number of entries in a table or array.
--------------------------------------------------------------------------------------------
| | |
| Columns 36-39 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| 1-9999 | The number of entries reserved by the compiler for the table or |
| (right-justified, | array. |
| leading zeros are | |
| not required) | |
| | |
| blank | This is not a table or array. |
| | |
--------------------------------------------------------------------------------------------
Tables and arrays can contain fewer entries during execution than you
specify, but not more. For alphanumeric tables and arrays, unused
entries contain blanks. For numeric tables and arrays, unused entries
contain zeros. You can add or replace entries in tables and arrays
during execution (see the section at the end of this chapter titled
"Tables and Arrays").
For alternating tables, each pair of related entries is considered one
table entry.
Example
The alternating tables (TABLEA and TABLEB) shown in Figure 5-3 have
50 entries each. To indicate this, 0050 is entered in columns 36-39 to
indicate the number of entries in the alternating tables.
________________________________________________________________________________
| |
| 1 2 3 4 5 6 7 |
| 678901234567890123456789012345678901234567890123456789012345678901234|
| _______________________________________________________ |
| |
| E TABLEA0030050010L2ATABLEB 12R4ATABLE FILE |
| |
| |
________________________________________________________________________________
Figure 5-3. Specifying the Number of Entries in Alternating Tables
Entry Length (Columns 40-42)
This field specifies the length of entries in a table or array.
--------------------------------------------------------------------------------------------
| | |
| Columns 40-42 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| 1-256 | The entry length (space allocated for each item). The maximum |
| (right-justified, | length for alphabetic entries is 256 characters; for numeric |
| leading zeroes are | entries, 15 digits |
| not required) | |
| | |
| blank | This is not a table or array. |
| | |
--------------------------------------------------------------------------------------------
Entries in each table or array must be the same length. If alphanumeric
entries are different lengths, add leading or trailing blanks to make
them the same length. If numeric entries are different lengths, add
leading or trailing zeros or blanks to make them the same length. If you
enter an L or R in the Data Format Field (column 43), include the sign
position in the length. For numeric tables and arrays in packed decimal
format, enter the unpacked decimal length. For numeric tables or arrays
in binary format, enter 5 for 16-bit numbers or 6 for 32-bit numbers
(this allocates 2 or 4 bytes, respectively, for the numbers).
If you're using the Calculation Specification LOKUP operation, make sure
the entry length is the same as the field being used as the search
argument.
If this table or array has an alternating table or array, enter the
alternating table or array length in the Entry Length Field (columns
52-54).
Data Format (Column 43)
This field identifies the data format for numeric compile-time or
preexecution-time tables and arrays.
--------------------------------------------------------------------------------------------
| | |
| Column 43 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| B | Binary format (1 or 2 word integer). |
| | |
| L | Unpacked decimal format with leading plus or minus sign. |
| | |
| P | Packed decimal format. |
| | |
| R | Unpacked decimal format with trailing plus or minus sign. |
| | |
| blank | Alphanumeric or unpacked decimal (with no leading or trailing |
| | signs) format. For unpacked decimal format, enter a digit (0-9) |
| | in the Decimal Positions Field (column 44). For alphanumeric |
| | format, leave column 44 blank. |
| | |
--------------------------------------------------------------------------------------------
If this table or array has an alternating table or array, enter the
format for the alternating table or array in the Data Format Field
(column 55).
For details about each of the formats, see the Data Format Field (column
43) of the Input Specification.
Decimal Positions (Column 44)
This field contains the number of decimal positions (positions to the
right of the decimal) in each entry of a table or array.
--------------------------------------------------------------------------------------------
| | |
| Column 44 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| 0-9 | This is a numeric table or array with the specified number of |
| | decimal positions in each field. (The number of decimal |
| | positions cannot exceed the number of digits in the field.) |
| | |
| blank | This is an alphanumeric table or array. |
| | |
--------------------------------------------------------------------------------------------
Since numeric entries in tables and arrays do not contain an actual
decimal point, this field determines where the decimal point is assumed
to be during calculations and output editing operations.
If this table or array has an alternating table or array, enter the
decimal positions for the alternating table or array in the Decimal
Positions Field (column 56).
Example
To specify that the entries in the following array have two decimal
positions, enter 2 in column 44 of the File Extension Specification.
ARRAY
0000
0100
0150
0200
0250
.
.
.
If the entries in this array were printed using edit code 1 (suppress
leading zeros), you would see:
.00 1.00 1.50 2.00 2.50...
Table/Array Sequence (Column 45)
This field lets you sequence-check compile-time and preexecution-time
tables and arrays.
Sequence-checking is not affected by the Alternate Collating Sequence
Field (column 26) of the Header Specification.
--------------------------------------------------------------------------------------------
| | |
| Column 45 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| A | Sequence-check the table or array for ascending order. |
| | |
| D | Sequence-check the table or array for descending order. |
| | |
| blank | Do not sequence-check the table or array; high and low LOKUP |
| | operations prohibited for unsequenced tables or arrays; binary |
| | searching prohibited. |
| | |
--------------------------------------------------------------------------------------------
Table and array entries can be arranged in ascending, descending, or
random order. In ascending order, the lowest data entry appears first,
followed by entries that consecutively increase in value according to the
ASCII Collating Sequence. In descending order, the highest data entry
appears first, followed by entries that consecutively decrease in value.
When you sequence-check an ascending or descending table or array, RPG
checks the order while loading it. If the compiler detects a sequence
error, processing halts immediately. The computer operator may then
continue processing in spite of the error, or terminate the program.
If this table or array has an alternating table or array, specify
sequence-checking for the alternating table or array in the Table/Array
Sequence Field (column 57).
Although RPG does not sequence-check execution-time arrays, you must
enter an A or D in this field to use LOKUP operations with high or low
indicators, or to perform binary searching.
Alternating Table/Array Name (Columns 46-51)
This field contains the name of the alternating table or array associated
with the table or array named in the Table/Array Name Field (columns
27-32). Do not enter the name of an execution-time array.
When you enter an alternating table or array into this field, you must
also enter the next four fields (through column 57).
--------------------------------------------------------------------------------------------
| | |
| Columns 46-51 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| Alternating table or array name | The name of the second alternating table or |
| | array. |
| | |
| blank | The table named in columns 27-32 does not have |
| | an alternating table or array. |
| | |
--------------------------------------------------------------------------------------------
Entry Length (Columns 52-54)
This field specifies the length of entries in an alternating table or
array. The length you enter in this field applies to the table or array
named in the Alternating Table/Array Name Field (columns 46-51).
--------------------------------------------------------------------------------------------
| | |
| Columns 52-54 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| 1-256 | The entry length (space allocated for each item). The maximum |
| (right-justified, | length for alphabetic entries is 256 characters; for numeric |
| leading zeroes are | entries, 15 digits |
| not required) | |
| | |
| blank | This is not a table or array. |
| | |
--------------------------------------------------------------------------------------------
Entries in each table or array must be the same length. If alphanumeric
entries are different lengths, add leading or trailing blanks to make
them the same length. If numeric entries are different lengths, add
leading or trailing zeros or blanks to make them the same length. If you
enter an L or R in the Data Format Field (column 55), include the sign
position in the length. For numeric tables and arrays in packed decimal
format, enter the unpacked decimal length. For numeric tables or arrays
in binary format, enter 5 for 16-bit numbers or 6 for 32-bit numbers
(this allocates 2 or 4 bytes, respectively, for the numbers).
If you're using the Calculation Specification LOKUP operation, make sure
the entry length is the same as the field being used as the search
argument.
Data Format (Column 55)
This field identifies the data format for the alternating compile-time or
preexecution-time table or array. Use this field only for numeric tables
and arrays. This field applies to the table named in the Alternating
Table/Array Name Field (columns 46-51).
--------------------------------------------------------------------------------------------
| | |
| Column 55 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| B | Binary format (1 or 2 word integer). |
| | |
| L | Unpacked decimal format with leading plus or minus sign. |
| | |
| P | Packed decimal format. |
| | |
| R | Unpacked decimal format with trailing plus or minus sign. |
| | |
| blank | Alphanumeric or unpacked decimal (with no leading or trailing |
| | signs) format. For unpacked decimal format, enter a digit (0-9) |
| | in the Decimal Positions Field (column 44). For alphanumeric |
| | format, leave column 44 blank. |
| | |
--------------------------------------------------------------------------------------------
For details about each of the formats, see the Data Format Field (column
43) of the Input Specification.
Decimal Positions (Column 56)
This field contains the number of decimal positions (positions to the
right of the decimal) in each entry of an alternating table or array.
This field applies to the table or array named in the Alternate
Table/Array Name Field (columns 46-51).
--------------------------------------------------------------------------------------------
| | |
| Column 56 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| 0-9 | This is a numeric table or array with the specified number of |
| | decimal positions in each field. (The number of decimal |
| | positions cannot exceed the number of digits in the field.) |
| | |
| blank | This is an alphanumeric table or array. |
| | |
--------------------------------------------------------------------------------------------
See the Decimal Positions Field (column 44) for an example of how to
enter this field.
Table/Array Sequence (Column 57)
This field lets you sequence-check an alternating compile-time or
preexecution-time table or array. Sequence-checking applies to the table
or array named in the Alternate Table/Array Name Field (columns 46-51).
Sequence-checking is not affected by the Alternate Collating Sequence
Field (column 26) of the Header Specification.
--------------------------------------------------------------------------------------------
| | |
| Column 57 | Description |
| | |
--------------------------------------------------------------------------------------------
| | |
| A | Sequence check the table or array for ascending order. |
| | |
| D | Sequence check the table or array for descending order. |
| | |
| blank | Do not sequence check the table or array; high or low LOKUP |
| | operations prohibited for unsequenced tables or arrays; binary |
| | searching prohibited. |
| | |
--------------------------------------------------------------------------------------------
Table and array entries can be arranged in ascending, descending, or
random order. In ascending order, the lowest data entry appears first,
followed by entries that consecutively increase in value according to the
ASCII Collating Sequence. In descending order, the highest data entry
appears first, followed by entries that consecutively decrease in value.
When you sequence-check an ascending or descending table or array, RPG
checks the order while loading it. If the compiler detects a sequence
error, processing halts immediately. The computer operator may then
continue processing in spite of the error, or terminate the program.
Although RPG does not sequence-check execution-time arrays, you must
enter an A or D in this field to use LOKUP operations with high or low
indicators, or to perform binary searching.
Comments (Columns 58-74)
You can enter comments of any kind in this field.
Program Name (Columns 75-80)
This field contains the program name. The format of this field is
discussed in Chapter 2.
MPE/iX 5.0 Documentation