Access files

A file must exist when compiling a CL module or OPM program that uses it.

The compiler accesses files when compiling a program module that has a Declare File (DCLF) command. The file does not have to exist when creating a program or service program that uses the module.

Enter Data Description Specifications (DDS) into a source file before creating it. The DDS describes the record formats and the fields within the records. Additionally, the system compiles this information to create the file object through the Create Display File (CRTDSPF) command.

Note: You can create other types of files from DDS, and each type has its own command: Create Physical File (CRTPF) and Create Logical File (CRTLF) are two that create files that you can use in CL programs and procedures.

The fields that are described in the DDS can be input or output fields (or both). The system declares the fields in the CL program or procedure as variables when it compiles a program or module. The program manipulates data from display through these variables.

If you do not use DDS to create a physical file, the system declares a CL variable to contain the entire record. This variable has the same name as the file, and its length is the same as the record length of the file.

CL programs and procedures cannot manipulate data in any types of files other than display files and database files, except with specific CL commands.

Deletion of the DDS after creating the file is possible but not recommended. You can delete the file after the system compiles the CL program or module that refers to the file. This is true provided the file exists when the command referring to it, such as a Receive File (RCVF), is processed in the program.

The rules on qualified names that are described here for command definitions also apply to files.

Related tasks
Work with files in CL procedures