Describing logical file record formats
For every logical file record format described with data description specifications (DDS), specify a record format name and either the PFILE keyword (for simple- and multiple-format logical files) or the JFILE keyword (for join logical files). The file names specified on the PFILE or JFILE keyword are the physical files that the logical file is based on. A simple or multiple-format logical file record format can be specified with DDS in any one of the following ways:
In the following example, a program needs:
- In the simple logical file record format, specify only the record format name and the PFILE keyword. The record format for the only (or first) physical file specified on the PFILE keyword is the record format for the logical file. The record format name specified in the logical file must be the same as the record format name in the only (or first) physical file. Consider this example of a simple logical file:
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A A R ORDDTL PFILE(ORDDTLP) A
- Describe your own record format by listing the field names you want to include. You can specify the field names in a different order, rename fields using the RENAME keyword, combine fields using the CONCAT keyword, and use specific positions of a field using the SST keyword. You can also override attributes of the fields by specifying different attributes in the logical file. Consider this example of a simple logical file with fields specified::
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A A R ORDHDR PFILE(ORDHDRP) A ORDER A CUST A SHPVIA A
- Specify the name of a database file for the file name on the FORMAT keyword. The record format is shared from this database file by the logical file being described. The file name can be qualified by a library name. If a library name is not specified, the library list is used to find the file. The file must exist when the file you are describing is created. In addition, the record format name you specify in the logical file must be the same as one of the record format names in the file you specify on the FORMAT keyword. Consider this example:
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A A R CUSRCD PFILE(CUSMSTP) A FORMAT(CUSMSTL) A
- The fields placed in a different order
- A subset of the fields from the physical file
- The data types changed for some fields
- The field lengths changed for some fields
You can use a logical file to make these changes.
![]()
For the logical file, the DDS would be as follows:
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A A R LOGREC PFILE(PF1) A D 10S 0 A A A C 5S 0 AFor the physical file, the DDS would be as follows:
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A A R PHYREC A A 8S 2 A B 32 A C 2B 0 A D 10 AWhen a record is read from the logical file, the fields from the physical file are changed to match the logical file description. If the program updates or adds a record, the fields are changed back. For an add or update operation using a logical file, the program must supply data that conforms with the format used by the logical file.
The following chart shows what types of data mapping are valid between physical and logical files.
Physical file data type Logical file data type Character or hexadecimal Zoned Packed Binary Floating point Date Time Timestamp Character or Hexadecimal Valid See Notes 1 Not valid Not valid Not valid Not valid Not valid Not valid Zoned See Notes 1 Valid Valid See Notes 2 Valid Not valid Not valid Not Valid Packed Not valid Valid Valid See Notes 2 Valid Not valid Not valid Not valid Binary Not valid See Notes 2 See Notes 2 See Notes 3 See Notes 2 Not valid Not valid Not valid Floating point Not valid Valid Valid See Notes 2 Valid Not valid Not valid Not valid Date Not valid Valid Not valid Not valid Not valid Valid Not valid Not valid Time Not valid Valid Not valid Not valid Not valid Not valid Valid Not valid Timestamp Not valid Not valid Not valid Not valid Not valid Valid Valid Valid Notes:
- Valid only if the number of characters or bytes equals the number of digits.
- Valid only if the binary field has zero decimal positions.
- Valid only if both binary fields have the same number of decimal positions.
- Describing field use for logical files
You can specify that the fields in a logical file be input-only, both (input/output), or neither fields.
- Deriving new fields from existing fields
Fields in a logical file can be derived from fields in a physical file on which the logical file is based or from fields in the same logical file.
- Describing floating-point fields in logical files
You can use floating-point fields as mapped fields in logical files.
Parent topic:
Setting up logical files
Related concepts
Double-byte character set considerations