Free-Form Subfield Definition
A free-form subfield definition begins with the subfield name, or it begins with the DCL-SUBF or DCL-DS operation code followed by the subfield name.
The DCL-SUBF operation code must be specified if the subfield name is the same as an operation code allowed in free-format calculations. See Table 1.
The DCL-DS operation code is used to define a nested data structure subfield.
The subfield name is followed by keywords, and finally a semicolon.
Program-described subfield
Specify *N for the subfield name if the subfield does not have a name.
If a data-type keyword is specified, it must be the first keyword.
If the subfield is a predefined subfield in the Program Status Data Structure or a File Information Data Structure, specify the subfield reserved word in place of the data type keyword.
In a free-form definition, the OVERLAY keyword can only be used to overlay one subfield on another subfield. If you don't want the subfield to be placed at the next available position in the data structure, use the POS keyword to specify the starting position.
Externally-described subfield
The first keyword for an externally-described subfield must be the EXTFLD keyword. If the subfield name is the same as the external name of the subfield, the parameter of the EXTFLD keyword may be omitted.
Program-described subfield
Specify *N for the subfield name if the subfield does not have a name.
If a data-type keyword is specified, it must be the first keyword.
If the subfield is a predefined subfield in the Program Status Data Structure or a File Information Data Structure, specify the subfield reserved word in place of the data type keyword.
In a free-form definition, the OVERLAY keyword can only be used to overlay one subfield on another subfield. If you don't want the subfield to be placed at the next available position in the data structure, use the POS keyword to specify the starting position.
Nested data structure subfield
You can define a data structure as a nested data structure subfield if the parent data structure is defined in free-form syntax and is qualified. The nested data structure subfield must also be defined in free-form syntax.
A nested data structure subfield is automatically qualified. In the following example, subfield address is defined as a nested data structure subfield. It begins with a DCL-DS statement ( 1 ), followed by subfields, followed by an END-DS statement ( 2 ). The subfields of the address subfield are qualified by person.address ( 3 ).
DCL-DS person QUALIFIED;
name VARCHAR(25);
DCL-DS address; 1
num int(5);
street VARCHAR(25);
city VARCHAR(25);
province VARCHAR(25);
postcode VARCHAR(6);
END-DS address; 2
age int(5);
END-DS person;
person.address.street = 'Elm Ave.'; 3
DCL-DS family QUALIFIED;
num int(5);
DCL-DS person DIM(10); 1
name VARCHAR(25);
age int(5);
numPets int(5);
DCL-DS pets DIM(5); 2
name VARCHAR(25);
type VARCHAR(25);
END-DS pets;
END-DS persom;
END-DS;
family.person(1).numPets = 1;
family.person(1).pets(1).type = 'fish'; 3
Subfield examples
See Free-Form Data Structure Definition for examples of free-form subfield definitions.