Previous Topic: Subschema ConsiderationsNext Topic: Navigational DML Programming Techniques


Copying Record Definitions and Their Synonyms

Typically, you copy subschema records into variable storage using the primary name that the record is known by in the schema. Synonyms are alternative names for existing dictionary entities. A given file, record, or element can have multiple names through the use of IDD synonyms. This allows all programs that use an entity such as a record to access the same entity definition but refer to it using a name that complies to the language in which the program is written.

Uses of Synonyms

Synonyms are typically used for the following reasons:

Terminology for Using Synonyms

You should be familiar with the following terms:

How the Precompiler Performs COPY IDMS

When the precompiler selects which record or synonym to copy into your program, it first checks to see if you have specified a VERSION clause in the COPY command. If no VERSION clause is given, a two-fold search is undertaken, first for a record associated with the subschema and then, if the first test fails, for an IDD-defined record.

To determine if the specified record is associated with the subschema, the precompiler performs the following steps:

  1. Forms a table of records defined in the subschema and their synonyms. This table contains all records copied into the subschema and, for every record copied, the names of its synonyms not copied into another subschema.
  2. Searches this table to match the name of the record in the COPY statement. If a match is found, that record is copied in; if no match is found, the search continues as described below.

If you specify a VERSION clause or if the test listed above fails, the precompiler assumes that the record is an IDD-defined record and performs the following steps:

  1. Identifies a candidate record. A record is a candidate if it has a synonym whose name matches the name specified in the COPY IDMS statement.
  2. Checks the builder code. The candidate record is tested for being either schema-owned (builder code of S) or a subschema view (builder code of V). If either is true, the record is rejected and another candidate is examined.
  3. Checks the VERSION clause. If a VERSION clause is specified on the COPY IDMS statement, the candidate record's version is compared to that specified. If they are not equal, the record is rejected and another candidate is examined.
  4. Checks the language attribute. If the candidate record has a language attribute and it is different than that of the compiler being used (for example, PL/I), the record is rejected and another candidate is examined.
  5. Checks the mode. The mode associated with the candidate record is compared with the operating mode specified in the program. If they match, the record remains a candidate. If there is no record with a match on mode and the candidate has a mode of NON-MODESPECIFIC, it remains a candidate. If there is no record with a matching mode or a mode of NON-MODESPECIFIC and the candidate has no mode associated with it, it remains a candidate. Otherwise, the record is rejected and another candidate is examined.
  6. Rechecks the VERSION clause. If a VERSION clause is specified on the COPY IDMS statement, the candidate record is chosen as the one to be copied into the program. If no VERSION clause is specified, the candidate with the highest version meeting all the above criteria is chosen.