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

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.

Type
*QUAL
Required
Yes
Case
Uppercase
*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

Type
*NAME
Required
No
Length
10
Case
Uppercase

Library Library

Type
*NAME
Required
No
Default
*LIBL
Length
10
Case
Uppercase

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.

Type
*NAME
Required
No
Default
*ALL
Length
10
List limit
50
Case
Uppercase

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.

Type
*SNAME
Required
No
Default
*NONE
Length
10
Case
Uppercase

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.

Type
*CHAR
Required
No
Default
*NO
Length
4
Case
Uppercase

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.

Type
*CHAR
Required
No
Default
*NO
Length
4
Case
Uppercase

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.

Type
*CHAR
Required
No
Default
*NO
Length
4
Case
Uppercase

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.

Type
*CHAR
Required
No
Default
*DEC
Length
4
Case
Uppercase

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.

IBM command documentation

Generated from os/cl/catalog/DCLF.json and os/cl/help/DCLF.json.