Where allowed to run:
|
Parameters Examples Error messages |
The Declare File (DCLF) command declares one file (by name) to a Control Language (CL) program. Up to five DCLF commands are allowed in a CL procedure. Each DCLF command specifies the name of a display file or database file, the file record formats to be used in the program, and an optional open file identifier which is used to uniquely identify the declared instance of the file within the CL procedure. Multiple DCLF commands can reference the same file, so long as the value specified for the Open file identifier (OPNID) parameter is unique. Following the DCLF command for a file, the CL procedure can contain data manipulation commands. For display files, the following commands can be used to send data to a workstation and receive data from a workstation: Send File (SNDF), Receive File (RCVF), Send/Receive File (SNDRCVF), End Receive (ENDRCV), and Wait (WAIT). For database files, the RCVF command can be used to read records from the file.
When the CL procedure is compiled, a CL variable is automatically declared for each field in each record format used in the program. If the file is a record-level database file, the record format contains one field with the name of that record format. If the value specified for the OPNID parameter is *NONE, the variable name is the field name prefixed with an ampersand (&). If the OPNID parameter value is not *NONE, the variable name is the field name prefixed with an ampersand (&), the value specified for the OPNID parameter, and an underscore.
For example, if a declared file has a record format with field CUSTNAME and the open file identifier specified on the DCLF command was FILE1, the declared variable would be:
&FILE1_CUSTNAME
The attributes of each declared field are the same as the attributes of the field in the file record format. Fields defined in the record format as numeric are defined as decimal variables. Indicators defined in the referenced file record format are declared as logical variables with a variable name in the form INnn, where 'nn' is the indicator number.
Variables automatically declared by the DCLF command can be used in the program the same as the variables declared by a DCL command. For example, indicators can be used in expressions and IF statements because they are declared as logical variables.
The content of the variables, not the variable names, are seen by the user; the display shows one, some, or all of the fields in the record format that can be filled in by the user. DDS determines the display format.
Restrictions:
Because CL variables are automatically declared for each field in a referenced file's record formats, the following restrictions apply:
The variables used in the file must have attributes that are valid for CL variables. For decimal variables, the limits are 15 digits and 9 decimal positions. For variables with more than 15 digits, CL will declare a character variable that is the number of digits, divided by 2, plus 1 (n / 2 + 1) in length. A CPI0306 message will be issued stating that the conversion has taken place, which can be seen in the program listing. For character variables, the limit is 32767 bytes.
Additional Considerations:
File processing is handled differently in CL procedures, depending on whether the file specified in the DCLF command is a display file or a database file.
The following statements apply if the file is a display device file at compile time:
The following statements apply if the file is a database file at compile time:
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
FILE | File | Qualified object name | Required, Positional 1 |
Qualifier 1: File | Name | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
RCDFMT | Record format | Single values: *ALL Other values (up to 50 repetitions): Name |
Optional, Positional 2 |
OPNID | Open file identifier | Simple name, *NONE | Optional |
ALWVARLEN | Allow variable length fields | *NO, *YES | Optional |
ALWNULL | Allow field value of null | *NO, *YES | Optional |
ALWGRAPHIC | Allow graphic fields | *NO, *YES | Optional |
DCLBINFLD | Declare binary fields | *DEC, *INT | Optional |
Top |
Specifies the file to be used by the CL procedure.
This is a required parameter.
Qualifier 1: File
Qualifier 2: Library
Top |
Specifies the names of one or more record formats contained in the file. These record formats are used by the Send File (SNDF), Receive File (RCVF), and Send/Receive File (SNDRCVF) commands in the CL procedure. Database files can be processed only by RCVF. CL variable names cannot be specified in RCDFMT; only names of record formats can be used. For every field and indicator in each record format specified in RCDFMT, one CL variable is automatically declared in the program.
Note: A physical file can contain only one record format. A logical file which has multiple record formats defined in DDS may be used if it is defined over only one physical file member. If the physical file contains more than one record format, an error message is sent and the compile procedure fails.
Single values
Other values (up to 50 repetitions)
Top |
Specifies the open file identifier to be associated with the file specified for the File (FILE) parameter. This identifier must be unique for all files declared in the CL program.
Top |
Specifies whether variable length fields are allowed in record formats.
Top |
Specifies whether a field value of null is allowed.
Top |
Specifies whether graphic data fields are allowed in record formats.
Top |
Specifies whether variables declared for binary fields in the record format should be packed decimal or integer.
Top |
Example 1: Declaring Fields of All Record Formats as Variables
DCLF FILE(ABLE) RCDFMT(*ALL)
This command specifies that the file named ABLE is used by the CL program to pass data between the user and the program. Because no library was specified, the library list is used to locate the file. All the fields and indicators in all the record formats are automatically declared as variables, and data from any field in any record format (up through the first 99) in the file can be passed between the program and the user.
Example 2: Using Multiple Record Formats
DCLF FILE(BAKER) RCDFMT(REC2 REC6)
Display file BAKER is used by the CL procedure to pass data between the user and the program. Assuming the library qualifier for FILE defaults to *LIBL, the library list is used to locate the file. Both the REC2 and REC6 record formats are used.
Example 3: Using an Open File Identifier
DCLF FILE(MYLIB/CHARLES) OPNID(CTLFILE1)
File CHARLES in library MYLIB is used by the the CL procedure to read records from the database file. If the record format contains a field named CUSTNUMBER, the following variable will be declared:
&CTLFILE1_CUSTNUMBER
Top |
None
Top |