Declares a subfield for a data structure.
DCLDSFLD
Name (name)
Type (*BINARY | *BOOLEAN | *BYTE | *CHAR | *DATE | *DECIMAL | *FLOAT | *FLOAT4 |
*FLOAT8 | *IND | *INTEGER | *INTEGER2 | *INTEGER4 | *INTEGER8 | *ONECHAR |
*PACKED | *TIME | *TIMESTAMP | *ZONED)
Len (Integer Literal, Interger Literal)
Dim (Integer Literal, Integer Literal, ...)
TimFmt (*PGMDFT | *DMY | *EUR | *HMS | *ISO | *JIS | *JUL | *MDY | *USA | *YMD)
Like (Field name)
Overlay (parentField, startPos | *Next)
OverlayArray (parentField, startPos | *Next)
Required. The name of the data structure subfield.
Optional. Type can be any of Special Value ( i.e., *CHAR, *BINARY, etc.) or it can be a class name. If Type is *BOOLEAN or *IND, you can use *ON, *TRUE, *ON and *FALSE figurative constants to indicate true and false and "1" and "0", respectively.
If a Type parameter is not given, the Len parameter is required. In this case, *CHAR is assumed if there is one integer given and *ZONED is assumed if there are two integers.
Optional. Len specifies the length of the field. If Len is decimal e.g. Len (3,1) *ZONED is assigned as the default. If Len is character e.g. Len (3), *CHAR is assigned as the default.
If Type is packed, then the length is not the number of bytes the packed field fits into, but rather the logical digit length of the field. For example, if you want a 7 digit packed with 2 decimals, code Len (7,2).
Optional. When Dim is specified, the DCLDSFLD is treated as an array with all the properties associated with a DCLARRAY statement.
Optional. TimFmt specifies the format for time, date, and timestamp variables. If the TimFmt parameter is not specified, the format specified by the program is assumed.
Optional. Like must be the name of a field already defined in the class. Type cannot be a named constant or a literal. In this case, the field will be defined based on the attributes of another field. If Type is an array, array element, or a table name, the attributes of an element of the array or table are used to define the field. You can use Len parameter to make the declared field longer or shorter than the Like parameter entry.
A plus sign (+) preceding the number indicates a length increase; a minus sign (-) indicates a length decrease. You cannot change the number of decimal positions for the field being defined. The field length entry is allowed only for field definitions requiring a length.
Optional. For Type *CHAR and *ZONED only. The OVERLAY keyword overlays the storage of one subfield with that of another subfield.
This subfield will overlay the storage specified by the overlaid name parameter at the position specified by the startpos parameter. If startpos is not specified, it defaults to 1.
The following rules apply to keyword OVERLAY:
If a subfield with overlaying subfields is not otherwise defined, the subfield is implicitly defined as follows:
If the subfield specified by overlaid name is an array, the OVERLAY keyword applies to each element of the array. See restrictions below.
That is, the field being defined is defined as an array with the same number of elements. The first element of this array overlays the first element of the overlaid array, the second element of this array overlays the second element of the overlaid array, and so on. No array keywords may be specified for the subfield with the OVERLAY keyword in this situation.
If the subfield specified by overlaid name is an array and its element
length is longer than the length of the subfield being defined, the array
elements of the subfield being defined are not stored contiguously.
Restrictions when the overlaid name is an array:
Under such a declaration, the subfield becomes a non-contiguous array and has the following usage limitations.
Optional. The OverlayArray keyword is used to define a field to overlay an array subfield. The elements of the array subfield will be concatenated into one large scalar field, before overlaying occurs ( RPG/400 behavior ).
This is in contrast to the Overlay keyword, which is an element-by-element overlay( RPG/ILE behavior ). Hence in-effect, using Overlay keyword to define an overlay field on an array subfield, the field will be defined as an Array; where as in OverlayArray, the field will be defined as a Scalar.
DCLDS Name(DS1) DCLDSFLD Name(DSFLD1) Type(*CHAR) Len(5) DCLDSFLD Name(DSFLD2) Type(*ZONED) Len(10,0) DCLDSFLD Name(OVERDSFLD) Type(*CHAR) Len(10) Overlay(DSFLD2)
// Declare a simple data structure with two subfields with one overlay of the 1st five characters of DSFLD2 DCLDS Name(DS1) DCLDSFLD Name(DSFLD1) Type(*CHAR) Len(5) DCLDSFLD Name(DSFLD2) Type(*CHAR) Len(10) DCLDSFLD Name(OVERDSFLD) Type(*CHAR) Len(5) Overlay(DSFLD2,1)
DCLDS
DclFmtCycleAttr
DCLOVERLAYGROUP
MOVEARR
Time, Date, and Timestamp variables