Free-Form Definition Statement
A free-form data definition statement begins with one of the declaration operation codes, followed by a name, or by *N if the item does not have a name, followed by keywords, and finally a semicolon.
The following are the declaration operation codes:
- DCL-C
- Define a named constant
- DCL-DS
- Define a data structure
- END-DS
- End a data structure
- {DCL-PARM}
- Define a parameter
- DCL-PI
- Define a procedure interface
- END-PI
- End a procedure interface
- DCL-PR
- Define a prototype
- END-PR
- End a prototype
- DCL-S
- Define a standalone field
- {DCL-SUBF}
- Define a subfield
The definition may be split across multiple lines if necessary.
The following are equivalent definitions:
- The definition is specified on a single line.
- The definition is split across multiple lines.
- The name is split across two lines, and the keyword is specified on the same line as the second part of the name.
- The name is split across two lines, and the
keyword is specified on line following the second part of the name.
Note: An ellipsis is not used following the last part of the name. In free-form specifications, an ellipsis is only used to join two parts of a name that are specified on different lines. It is not used to join a name to the remainder of the statement.
DCL-S abcdefghij CHAR(10); 1
DCL-S 2
abcdefghij
CHAR
(
10
)
;
DCL-S abcde... 3
fghij CHAR(10);
DCL-S abcde... 4
fghij
CHAR(10);
The only directives that are allowed within a free-form
data definition statement
are /IF, /ELSEIF, /ELSE, and /ENDIF.
DCL-S G_Working_Date DATE(*ISO)
/IF DEFINED(main_module)
EXPORT INZ(*SYS)
/ELSE
IMPORT
/ENDIF
;
Note: Specifying DCL-PARM or DCL-SUBF is optional unless the
name of the item is the same as an operation code
allowed in free-form calculations.
If a data structure defined without the LIKEREC or LIKEDS keywords
begins with a free-form statement, or any of the subfields are
specified with free-form statements, the data structure
must end with an END-DS statement.
DCL-DS ds1;
subf1 CHAR(10);
END-DS;
D ds2 DS
subf2 CHAR(10);
END-DS;
DCL-DS ds3;
D subf3 10a
END-DS;
Similarly, if a prototype or procedure interface
begins with a free-form statement, or any of the parameters are
specified with free-form statements, the prototype or procedure
interface must end with an END-PR or END-PI statement.
DCL-PR pr1;
subf1 CHAR(10);
END-PR;
D pr2 PR
parm2 CHAR(10);
END-PR;
DCL-PI pi3;
D parm3 10a
END-PI;
If a data structure has no subfields, END-DS may be specified as part of the
DCL-DS statement, immediately before the semicolon.
DCL-DS ds1 LEN(100) END-DS;
Similarly, if a procedure interface or prototype has no parameters,
the END-PI or END-PR may be specified as part of the DCL-PI or DCL-PR
statement, immediately before the semicolon.
DCL-PR pr1 INT(10) END-PR;