EGL sets the field when it reads from a file into the record, and uses the field to determine how many bytes to write to the file. The maximum length for the record is based on the fields defined for the record. When a variable-length record is written to a file, the value in the field specified by lengthItem must be less than or equal to the maximum length.
The length field is an integer of no more than 9 digits.
When you use a variable-length record, you must specify the lengthItem property, or the numElementsItem property, or both. If both properties are present when EGL writes the record to the file, it uses the numElementsItem field to calculate the total length of the record, and then places that length in the variable specified by lengthItem before writing the record. For more information, see Variable-length records.
Record SerialRecordPart1 type serialRecord { fileName = "myFile", lengthItem = myOtherField } 10 myField01 BIN(4); // 2 bytes long 10 myField02 NUM(3); // 3 bytes long 10 myField03 CHAR(20); // 20 bytes long end myOtherField NUM(4);
Platform | Issue |
---|---|
DL/I | The lengthItem variable
contains the name of the field in the DL/I segment that contains the
length of the entire segment, including the field itself. You must
specify the lengthItem if the segment has
a variable length. The field must be a SMALLINT and have the same
length and offset as the length field in the segment in the DL/I database
description. The field that lengthItem points to is usually the first field in the segment. However, this is not the case when a concatenated segment in a logical database is built from a fixed-length segment followed by a variable-length segment. |
WebSphere® MQ | When a program adds the record to a message queue, the message length is set equal to the value in the variable that the lengthItem property specifies. When a program reads the message from the queue, the message length is returned in the variable specified by the lengthItem property. If you specify variable names for both the lengthItem and the numElementsItem properties, the lengthItem variable is set to the length calculated from the number of elements in the record before a message is added to the queue. |
For other platform and resource association issues, see the "Compatibility" section of numElementsItem.