DDS for physical and logical files

Length for physical and logical files (positions 30 through 34)

For a physical file, use these positions to specify the field length for each named field (unless you copy it from a referenced field). Specify the number of digits for a numeric type field, or specify the number of characters for a character type field.

For a logical file, use these positions to specify the length of a logical field. Specify the length only to override or change the length of the corresponding field in the physical file on which this logical file is based. If you leave this position blank, the field you are defining has the same length as the corresponding field in the physical file(s) on which the logical file(s) is based. If the field in the physical file is variable length and you leave the length blank, the field is also variable length in the logical file. If you do specify a length, the field in the logical file is fixed length unless you also specify the VARLEN keyword. Additionally, the SST (Substring) keyword may be used to control the length of a logical file field by specifying a character string that is a subset of another field. For more information about SST keyword, see "SST (Substring) keyword--logical files only".

If you specify length, it must be right-justified; leading zeros are optional.

Figure 16 shows correct and incorrect field length specifications for a physical file.

Figure 16. Correct and Incorrect Length Specifications for Physical Files

|...+....1....+....2....+....3....+....4....+....5
00010A            FIELD1       7
     A
00020A            FIELD2         7
     A
00030A            FIELD3    R   +7
     A
 
Note:
FIELD1 shows the field length specified incorrectly. FIELD2 and FIELD3
show the field length specified correctly.

Valid length specifications are:

Data Type
Valid Lengths
Character
1 through 32 766 characters
Hexadecimal
1 through 32 766 bytes
Binary
1 through 18 digits
Binary Character
1 through 32 766 characters
Zoned decimal
1 through 63 digits
Packed decimal
1 through 63 digits
Floating-point
(single precision)
1 through 9 digits
Floating-point
(double precision)
1 through 17 digits
Date
6, 8, or 10 characters
Time
8 characters
Timestamp
26 characters

The length for fields with data type L (date), T (time), or Z (timestamp) is determined by the system. You should not enter a field length in positions 30 through 34.

The field length for date and time includes the separator.

A timestamp has a fixed format that has the following form:

YYYY-MM-DD-hh.mm.ss.uuuuuu

Type in a maximum of 9 digits for single precision and 17 digits for double precision. The OS/400 program supports a floating-point accuracy of 7 digits for single precision and 15 digits for double precision.

The total number of bytes occupied by all the fields in a record must not exceed 32 766 (in storage). See Table 1 for rules on determining the total length of the record format.

The system determines the number of bytes actually occupied in storage as follows:

Data Type
Bytes Occupied in Storage
Character
Number of characters
Hexadecimal
Number of bytes
Binary
1 through 4 digits
2 bytes
5 through 9 digits
4 bytes
10 through 18 digits
8 bytes
Binary Character
Number of characters
Zoned decimal
Number of digits
Packed decimal
(Number of digits/2) + 1 (truncated if fractional)
Floating-point
(single precision)
4 bytes
Floating-point
(double precision)
8 bytes
Date
10 characters without DATFMT keyword
and 6, 8 or 10 characters with DATFMT keyword
Time
8 characters
Timestamp
26 characters
Note:
The system performs arithmetic operations more efficiently for a packed decimal than for a zoned decimal data type.

Table 1 describes the rules for determining total format length.

Table 1. Rules for Determining Total Format Length

Situation Action
Does the record format contain any variable-length fields?
  1. Add an extra 24 bytes to the total format length.
  2. Add an extra 2 bytes to the format length for each field that is variable length.

Does the record format contain any fields that allow the null value? Divide the total number of fields in the format by 8, round up to the next highest whole byte, then add to format length.

To override the length of a referenced field (R in position 29) of a physical file or the length of the field in a logical file, either specify a new value or a change in length. To increase the length, specify +n, where n is the amount of increase. To decrease the length, specify -n, where n is the amount of decrease. For example, type +4 to indicate that a numeric field is to be 4 digits longer than the referenced field. See Figure 3 for an example showing how to override the field length for a physical file. Figure 1 shows how to change and override the field length for a logical file.

If the corresponding field in the physical file record format has a data type of binary with decimal positions greater than zero, the length cannot be overridden in the logical file. If the field you are describing is a concatenation of fields from the associated physical record format, you cannot specify the length in the logical file. The sum of the physical field lengths is calculated by the system.

If you specify a value in positions 30 through 34, your program sees the specified length. However, the length of the field in the corresponding physical file field does not change. This can cause data conversion errors. When attempting to add a member to a file or to open a member of a file, the OS/400 program may send a mapping error message. The OS/400 program may also send a mapping error message to your program in the following cases:

For example, if the physical file field is defined as 4 characters long and the logical file field decreases the length to 2 characters, a value of ABCD in the physical file cannot be read by the program, although a value of AB can. In this case, the program can always write successfully. For character fields, the data is left-justified and filled with blanks in the physical file field. For numeric fields, the data is right-justified and filled with zeros in the physical file field.

Positions 30 through 34 are valid only for field specifications. You must leave these positions blank at the key field, select/omit field, join, record, and file level.

Note:
High-level languages can impose restrictions on the field length. Any length restrictions should be observed for files used by these high-level languages.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]