Translating Data from Another File

The TFILE (file translation) code eliminates the need for duplicating data in related files by retrieving data from one file for use in another file. To access the remote file, the dictionary entry that contains the TFILE correlative must be created with the AMC specifying the attribute of the source item which provides the item-IDs for items in the target file.

Assume that a user wants to be able to generate reports from the ORDERS file that include book titles and prices. This information is contained in the BOOK-CATALOG file in Attributes 2 and 3, respectively. The item-IDs in BOOK-CATALOG are unique character strings (PRODUCT) that identify each book.

The ORDERS file also uses the PRODUCT attribute, but as Attribute 1. Since PRODUCT can be used to link the data in the ORDERS and BOOK-CATALOG files, this is the only piece of data required in the ORDERS file to uniquely identify a book.

The table below shows the Attribute Definition items for TITLE and PRICE in the ORDERS file:

Item-ID

TITLE

PRICE

D/CODE

S

S

A/AMC

1

1

S/NAME

 

 

V/CONV

 

 

V/CORR

TBOOK-CATALOG;X;;2

TBOOK-CATALOG;X;;3

V/TYP

T

R

V/MAX

40

8

The TFILE correlative for TITLE specifies that the data should be retrieved from Attribute 2 of the BOOK-CATALOG file. The TFILE correlative for PRICE specifies Attribute 3 of the BOOK-CATALOG file. The X subcode shown for both TITLE and PRICE causes a null value to be returned if for any reason the data cannot be retrieved.

With the preceding TFILE correlatives in place, lengthy titles need not be duplicated in each order item. In addition, the price of any book in the BOOK-CATALOG file could be changed, and reports generated from the ORDERS file would automatically reflect the new data.

See Also

Correlatives and Conversions

Stored Format and Output Format

Manipulating Existing Data