A STRUCTURE field description statement defines a field that is divided into one or more subordinate fields.
1 – Syntax Rules
o The field name you assign can be up to 31 characters from the set A-Z, 0-9, _, and $. The first character must be a letter from A-Z, and the last character can not be _ or $. You can use 8-bit alphabetic characters in field names. o If you use an asterisk (*) instead of a field-name, you create an unnamed field. o If you do not specify a data type for the STRUCTURE, the CDDL assigns it the UNSPECIFIED data type. o Subordinate field description statements describe contiguous portions of the field described by the STRUCTURE. o There must be at least one subordinate field description statement. A subordinate field can be an elementary, a STRUCTURE, a COPY, or a VARIANTS field. o CDDL accepts the keyword GROUP as a synonym for STRUCTURE, but the compiler issues a warning when you use GROUP. o You must terminate the STRUCTURE and the END statements with periods.
2 – Usage Notes
o Unnamed fields are similar to FILLER fields in VAX COBOL. You can use them to format print records or to reserve space in a record for future additions. o In a STRUCTURE field, you can use any field attribute clauses allowed in an elementary field. However, if you use the DATATYPE field description statement, you cannot create subordinate fields that exceed the length of the structure field. o A STRUCTURE field cannot contain the VIRTUAL FIELD datatype. o Although the CDDL compiler accepts data type specifications for STRUCTURE fields, the feature can not be supported by the language or language processor you use with the CDD. Make sure the definitions you store in the dictionary are valid for the processor that will use them. o All fields, except BIT fields, begin on the first byte following the preceding field. BIT fields begin on the bit immediately following the preceding field. You can modify this starting position with the ALIGNED clause.
3 – Example
You can nest STRUCTURE field description statements. The STRUCTURE field ADDRESS, for example, has a subordinate STRUCTURE field, ZIP_CODE. ADDRESS STRUCTURE. STREET DATATYPE IS TEXT SIZE IS 30 CHARACTERS. CITY DATATYPE IS TEXT SIZE IS 30 CHARACTERS. STATE DATATYPE IS TEXT SIZE IS 2 CHARACTERS. ZIP_CODE STRUCTURE. NEW DATATYPE IS UNSIGNED NUMERIC SIZE IS 4 DIGITS BLANK WHEN ZERO. OLD DATATYPE IS UNSIGNED NUMERIC SIZE IS 5 DIGITS. END ZIP_CODE STRUCTURE. END ADDRESS STRUCTURE.