Detection of file description changes
When a program that uses externally described files is compiled, the high-level language compiler extracts the record-level and field-level descriptions for the files referred to in the program and makes those descriptions part of the compiled program.
When you run the program, you can verify that the descriptions with which the program was compiled are the current descriptions.
The system assigns a unique level identifier for each record format when it creates the associated file. The system uses the following information to determine the level identifier:
- Record format name
- Field name
- Total length of the record format
- Number of fields in the record format
- Field attributes (for example, length and decimal positions)
- Order of the field in the record format
It is possible for files with large record formats (many fields) to have the same format level identifiers even though their formats might be slightly different. Problems can occur when copying these files if the record format names of the from-file and the to-file are the same.
Display, printer, and ICF files can also use the number of and order of special fields called indicators to determine the level identifier.
If you change the DDS for a record format and change any of the items in the preceding list, the level identifier changes.
To check the record format identifiers when you run the program, specify LVLCHK(*YES) on the create file or change file commands.
The level identifiers of the file opened and the file description that is part of the compiled program are compared when the file is opened and LVLCHK(*YES) is specified. The system does a format-by-format comparison of the level identifiers. If the identifiers differ or if any of the formats specified in the program do not exist in the file, a message is sent to the program to identify the condition.
When the identifiers differ, this means that the file format has changed. If the changes affect a field that your program uses, compile the program again for it to run properly. If the changes do not affect the fields that your program uses, you can run the program without compiling again by entering an override command for the file and specifying LVLCHK(*NO). Specifying LVLCHK(*NO) causes the system to omit the level identifier check when the file opens. For example, suppose that you add a field to the end of a record format in a database file, but the program does not use the new field. You can enter the Override with Database File (OVRDBF) command with LVLCHK(*NO) to enable the program to run without compiling again.
There are several CL commands available to you to check the changes. You can use the Display File Field Description (DSPFFD) command to display the record-level and field-level descriptions or, if you have the source entry utility (SEU), you can display the source file containing the DDS for the file. You can display the format level identifier that is defined in the file by using the Display File Description (DSPFD) or the DSPFFD commands. The format level identifier which was used when the program was created can be displayed by the Display Program References (DSPPGMREF) command.
There are also some changes to a file description that will not cause an error when the file opens. These happen because the record format identifiers did not change or because your program does not use the changed formats. You can add or remove formats from a file without affecting existing programs that do not use the added or deleted formats.
Even though the level identifier does not change, some DDS functions that you add or delete can require changes in the logic of your program. You should review the functions you added or deleted to determine whether the program logic requires changes.
Normally, the use of LVLCHK(*YES) is a good file integrity practice. The use of LVLCHK(*NO) can produce unpredictable results.
Parent topic:
Opened files