You are here: Defining Files and Fields > Editing Table Layouts > Field Arrays

Field Arrays

Overview

Analyzer provides the ability to process field arrays. This capability is designed for applications of COBOL OCCURS clauses or similar situations where a field or group of fields, repeats a number of consecutive times within a record.

To allow processing of field arrays, a field offset is specified for each repeating field by clicking on the Advanced button and then entering the length of the field array element in the OFFSET edit box.

A field array element is defined as a repeating field or set of repeating fields. The field offset is always the length of the field array element (i.e. the length of a repeating field or set of repeating fields).

Tip: Only define a repeating field once based on the actual physical position of the first occurrence within the record.

The default field offset value is zero, so field arrays will have no effect unless a field offset (for the field array element) is specified that is a positive whole number.

Note: When defining data using COBOL copybooks, the offset information is automatically initialized, based on the OCCURS clauses encountered.

Example 1

If you have a field array containing 12 consecutive packed fields called "Amount" with a field length of 5 bytes each (for a total of 60 bytes), which reflect monthly totals for the current year (1st=Jan, 12th=Dec), then the field array offset value should be specified as 5.

Example 2

If you have a field array consisting of 12 consecutive grouped sets of fields, containing a 5 byte “Amount” field plus a 12 byte “Description” field (for a total length of 17 bytes) then the field array offset value should be specified as 17.

Referencing Field Arrays

To access individual elements within a field array (most commonly within an Analyzer procedure) you must specify the field name followed by square brackets containing the desired element number (subscript). The array subscript can be any valid whole positive number or numeric expression.

Example 3

To access the fifth element within 12 consecutive packed field values called "Amount" (as described in Example 1 or 2 shown above), specify:

AMOUNT[5]

To total all of the MAY amounts (the fifth element in the field array for each record), specify:

TOTAL AMOUNT[5]

Note: If the value of a field array element is specified that does not exist within the record, Analyzer returns a blank or zero value as appropriate.

An alternate approach to working with repeating fields is to use the OFFSET() function. For more information, see OFFSET().