TRNTBL (Translation Table) keyword—logical files only

Use this field-level keyword to specify the name of a translation table to be used when passing this field between the physical file on the PFILE or JFILE keyword and your program.

The field must be a character field and its length cannot be redefined in the logical file. If the TRNTBL keyword is specified with the CONCAT keyword, the fields specified on the CONCAT keyword must all be character fields.

The format of the keyword is:
TRNTBL([library-name/]translation-table-name)

The translation-table-name is a required parameter value; the library-name is optional. If you do not specify the library-name, the operating system uses the library list (*LIBL) that is in effect at file creation time.

The translation-table-name cannot name an ICU table.

This keyword is valid only for character fields that are input-only (I specified in position 38) or neither (N specified in position 38) fields.

You cannot specify the TRNTBL keyword on a hexadecimal field (H in position 35). Do not specify the TRNTBL keyword on a date, time, or timestamp field (L, T, or Z in position 35).

You can specify as many as 99 different translation tables for different fields in the same logical file.

Translation occurs when the field is read from the physical file. Therefore, all functions specified in the logical file (such as key field sequencing, select/omit processing, and joining of records) depend on the translated version of the data.

The TRNTBL keyword changes the data in the records returned from the logical file. The ALTSEQ keyword changes only the order of the records returned from the logical file.

The TRNTBL keyword is similar to the CHRID keyword but differs from the latter as follows:
  • The TRNTBL keyword names the translation table to be used; the CHRID keyword does not.
  • The TRNTBL keyword changes data on input to the program when your program is reading a logical file. The CHRID keyword changes the data for display or printing on a specific device. Use the TRNTBL keyword when your program will use the changed data (for example, in an IF-THEN-ELSE statement or a COBOL SORT statement). If your program is handling data that comes only from a logical file, you do not need to specify the CHRID keyword in display or printer files used by the program.

The TRNTBL keyword is not valid when you specify FILETYPE(*SRC) on the Create Logical File (CRTLF) command.

Notes:
  1. When you use the TRNTBL keyword, the length of the field in the logical file must be the same as the length of the corresponding field in the physical file.
  2. At file creation time, you must have use authority to the translation table. The translation table is created using the Create Table (CRTTBL) command.
  3. The translation table specified in the TRNTBL keyword is referred to only when the logical file is created. Therefore, a change to a translation table does not affect the logical file until the logical file is re-created.

Example

The following example shows how to specify the TRNTBL keyword.

|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
00010A          R RECORD1                   PFILE(PF1)
00020A            CHAR1              I      TRNTBL(LIB1/TBL1)
00030A            CHAR2           A  I      TRNTBL(LIB2/TBL2)
00040A            NUM1
00050A            NUM2
     A

Field CHAR1 is translated using table TBL1 in library LIB1. Field CHAR2 is translated using table TBL2 in library LIB2. Field CHAR2 was redefined in the logical file as a character field (A in position 35) to allow the TRNTBL keyword to be specified. Fields NUM1 and NUM2 are numeric fields in the physical file PF1 and cannot have the TRNTBL keyword specified for them.