numElementsItem

The numElementsItem property identifies a field that is used when your code works with a variable length record.
The numElementsItem property is used with the following record stereotypes:

The variable-length record must have a structured field array as the last, top-level structure field. The field that numElementsItem references is an integer of no more than 9 digits that contains the actual number of array elements that are written. The value can range from 0 to the maximum, which is the number of elements specified in the declaration for the structured field array.

The number of bytes written is equal to the sum of the following values:

The numElementsItem field must be a field in the fixed-length part of the variable-length record. Use an unqualified reference to name the number of elements field. For example, use myField02 rather than myRecord.myField02.

The numElementsItem property has no effect when you are reading the record from a file.

You must specify the lengthItem property, or the numElementsItem property, or both, when you use a variable-length record. 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.

Example

The following example shows a variable-length Record part with the numElementsItem property:
  Record SerialRecordPart2 type serialRecord
    {
      fileName = "myFile",
      numElementsItem = myField02
    }
    10 myField01 BIN(4);   // 2 bytes long
    10 myField02 NUM(3);   // 3 bytes long
    10 myField03 CHAR(20)[3]; // 60 bytes long
       20 mySubField01 CHAR(10);
       20 mySubField02 CHAR(10);
  end

Assume you are writing a record based on SerialRecordPart2 with the numElementsItem field myField02 set to 2. EGL will write a variable-length record that contains myField01, myField02, and the first two elements of myField03.

Compatibility

Table 1. Compatibility considerations for numElementsItem
Platform Issue
CICS Variable length records are not supported for temporary storage queues and transient data queues.
IMS/VS numElementsItem and lengthItem are supported only for serial files associated with IMS message queues. EGL adds the IMS message header (length, ZZ field, and transaction code) to records it writes to a queue; EGL removes the header from records it reads from the queue. The definition for the record should not include the header.
IMS BMP For files associated with IMS message queues, the considerations for IMS/VS apply to IMS BMP. Otherwise, the considerations for z/OS batch apply.
iSeriesC Not supported.

Java Generation
Debug

Java and debug support variable-length records with the seqws, mq, and ibmcobol file types.
z/OS batch

Variable-length records are supported for VSAM files and z/OS sequential files.

Variable-length records in non-VSAM sequential files have a 4-byte header (2-byte length field and 2-byte filler field). EGL adds the 4-byte variable length header when writing to a non-VSAM sequential file with variable record format; EGL removes the header when it reads the record. The definition for the record should not include the header.

If the file is a GSAM file, EGL adds the 2-byte leading length field to records when writing to the file; EGL removes the header from records it reads from the file. The definition for the record should not include the header.


Feedback