Command reference / CL
DCLF
Declare File
Declares one display file or database file to a CL program or ILE CL procedure so its record formats can be used. Up to five DCLF commands are allowed per program. An optional open file identifier (OPNID) distinguishes multiple declarations of the same file. The compiler declares a CL variable for each field and indicator in the chosen record formats, named &<OPNID>_<FIELD> (or &<FIELD> when OPNID is *NONE). With display files, SNDF, RCVF, SNDRCVF, ENDRCV and WAIT can be used. With database files, only RCVF can be used.
Allowed environments: *BPGM, *IPGM.
Use within a CL program.
Positional parameters: 2.
Restrictions
- Valid only in a CL program or ILE CL procedure. DCL, COPYRIGHT, DCLF and DCLPRCOPT must follow PGM and precede all other commands.
- The file must be a database file with one record format, or a display file. Mixed files are not allowed.
- The database file may be physical or logical, and field-level or non-field-level. The file must exist before the program is compiled.
- If the file changes and level checking applies, the CL program must be recompiled.
- Fields with the same name in different record formats must have matching attributes, and any matching DCL variable must match the DDS attributes.
- Packed and zoned decimal fields become decimal variables. Binary fields become decimal variables unless DCLBINFLD(*INT) applies (under 10 digits, precision 0). Decimal variables are limited to 15 digits and 9 decimal positions; character variables to 32767 bytes.
- Display files are opened for input and output and may use SNDF, RCVF, SNDRCVF, ENDRCV and WAIT. Database files are opened for input only, may use only RCVF, are opened implicitly by RCVF, and are closed at program end or by CLOSE.
Parameters
FILE
File
Specifies the file the CL program or ILE CL procedure uses. This parameter is required. The library qualifier can be a name or a special value.
*LIBL- All libraries in the library list for the current thread are searched until the first match is found.
*CURLIB- The current library for the job is used. If there is no current library entry in the library list, QGPL is used.
Qualified parts (object, then library; write LIBRARY/OBJECT)
File
File
Library
Library
Suggested / special values:
*LIBL, *CURLIB
RCDFMT
Record format
Names one or more record formats whose fields are declared as CL variables. The formats are used by SNDF, RCVF and SNDRCVF, and up to 50 names can be given. Only record format names can be specified, not CL variable names.
Suggested / special values:
*ALL
*ALL- Every record format in the file, up to 99, has its fields declared. If there are more than 99, only the first 99 are used.
OPNID
Open file identifier
Sets the identifier for the file, which must be unique among files declared in the program. Only one file in a program can use *NONE.
Suggested / special values:
*NONE
*NONE- The file has no open file identifier.
ALWVARLEN
Allow variable length fields
Specifies whether variable length fields are allowed in record formats.
Allowed values:
*NO, *YES
*NO- Variable length fields are not allowed in record formats.
*YES- Variable length fields are allowed. Their CL variables are *CHAR with 2 bytes plus the maximum field length, and the first 2 bytes hold the data length after RCVF.
ALWNULL
Allow field value of null
Specifies whether a field value of null is allowed.
Allowed values:
*NO, *YES
*NO- Null values are not allowed. At RCVF, a diagnostic message with a single escape message is sent for the record and default values are placed in the CL variables.
*YES- Null values are allowed.
ALWGRAPHIC
Allow graphic fields
Specifies whether graphic data fields are allowed in record formats.
Allowed values:
*NO, *YES
*NO- Record formats cannot contain graphic data fields. A compile-time diagnostic is sent if the file supports them.
*YES- Record formats can contain graphic data fields. Their CL variables are *CHAR with a length in bytes equal to the field length.
DCLBINFLD
Declare binary fields
Specifies whether CL variables for binary fields in the record format are packed decimal or integer.
Allowed values:
*DEC, *INT
*DEC- CL variables for binary fields use TYPE(*DEC).
*INT- CL variables for binary fields with precision zero and a length of 9 or less use TYPE(*INT).
Examples
DCLF FILE(ABLE) RCDFMT(*ALL)
File ABLE is used to pass data between the user and the program. The library list is used to locate it. All fields and indicators in all record formats (up to the first 99) are declared as variables.
DCLF FILE(BAKER) RCDFMT(REC2 REC6)
Display file BAKER is used to pass data between the user and the program. The library list is used to locate it, and record formats REC2 and REC6 are used.
DCLF FILE(MYLIB/CHARLES) OPNID(CTLFILE1)
Database file CHARLES in library MYLIB is used to read records. If the record format has a field CUSTNUMBER, the variable &CTLFILE1_CUSTNUMBER is declared.
Generated from os/cl/catalog/DCLF.json and os/cl/help/DCLF.json.