Specifying record identification criteria

Where your copybook or template contains multiple records types, each type is initially distinguished by the record length. Provided that each type has a unique record length, you can select and display the various types. However, if two or more of the record types have the same length, you need to supply some record identification criteria. This usually takes the form of a field that contains a value unique to each record of the same type.

For example, in the following copybook definition, the Orders and Item records are of different lengths. As such, they can be selected and displayed without additional identification criteria.

   05 ORDER-ID        PIC X(5).
   05 CUSTOMER-ID     PIC X(5).
      10 ORDER-YEAR   PIC 9(4).
      10 ORDER-MONTH  PIC 9(2).
      10 ORDER-DAY    PIC 9(2).
01 ITEM.
   05 PRODUCT-ID      PIC X(9).
   05 QUANTITY        PIC 9(4) BINARY.
   05 UNIT-COST       PIC 9(8) BINARY.

However, if the records are of identical length, such as in the sample copybook shown below, Z Data Tools is unable to distinguish between these records unless some record identification criteria is used. By examining the data, we can determine that in all REC-TYPE01 records, the REC-TYPE field contains the value '01', and in all REC-TYPE02 records, the REC-TYPE field value is '02'. In this case, both record types include a REC-TYPE field, however, each record type does not need to use the same field in its identification.

01 REC-TYPE01.
   05 REC-TYPE                     PIC XX.
   05 NAME                         PIC X(20).
   05 EMPLOYEE-NO                  PIC 9(4) BINARY.
   05 AGE                          PIC 9(4) BINARY.
   05 SALARY                       PIC 9(7) PACKED-DECIMAL.
   05 MONTH                        PIC 9(8) BINARY OCCURS 12 TIMES.
   05 FILLER                       PIC XX.
01 REC-TYPE02.
   05 REC-TYPE                     PIC XX.
   05 NAME                         PIC X(20).
   05 JOB-TITLE                    PIC X(14).
   05 ADDR1                        PIC X(20).
   05 ADDR2                        PIC X(20).
   05 POSTCODE                     PIC X(4).

If any record types in your data have the same record length, it is strongly recommended that you specify record identification criteria to allow Z Data Tools to distinguish between them. Otherwise, the results can be unpredictable.

Even if the length of each record type is unique, it is still recommended that you specify record identification criteria for every record type, to help isolate records that match the length of a valid record type but contain data that is invalid for that type.

To specify record identification criteria:

  1. On your entry panel, specify a copybook or copybook template that contains more than one record type and edit the template.

    This can be done in a number of ways. For example, from the View Entry, Edit Entry or various Utilities panels, you can select the Edit Template option; on the View or Edit panels, you can enter the TE command; or on the Template Workbench panel, you can enter the E command.

    The Record Type Selection panel is displayed.

  2. In the Cmd field adjacent to the type you want to edit, type the E prefix command and press Enter.

    The Field Selection/Edit panel is displayed.

  3. Do one of the following:
    • Enter a freeform expression in the Record Identification Criteria field.
    • Type 1 on the Command Line and press Enter, then specify your record identification criteria by field.

      The Record Identification Criteria panel is displayed. This panel is identical to the Dynamic Template panel, except that:

      • the Field Name, Start, Length and Type fields are not editable;
      • in an 80 x 24 display, the Field Name field is displayed by default (instead of the Start, Length and Type fields);

      When you exit, the expression created is returned to the Record Identification Criteria field on the previous panel.

    Note: Freeform criteria expressions and “criteria by field” expressions are mutually exclusive.

Once your records can be identified by type (either by the record length or by record identification criteria), Z Data Tools automatically suppresses the display of all but one record type, depending upon the setting of the editor option Expose (do not group) records of types: Suppressed. By default, the first record type identified is displayed.

Related topics

Related concepts