About copybook templates

Copybook templates are templates where the field definitions are derived from one or more copybooks. A copybook is a member containing either COBOL data descriptions, PL/I DECLARE statements, or HLASM data definitions. Every copybook template has a source definition.
Source definition
The source definition describes the copybook members, their corresponding data sets, and how the field definitions are to be arranged in a template. The simplest form of source definition is a single copybook that contains all the record layouts required in their correct form. Single copybook source definitions can be referred to directly and a copybook template is built automatically from them.

Alternatively, you can provide an advanced copybook source definition that describes one or more copybook members, inserted level-01 data items, the range of statements to be included, and how REDEFINES or UNION clauses are to be interpreted in terms of record layouts.

A single copybook source definition can be the entire source of a program or only field definitions.

An advanced copybook source definition must refer to fields definitions for the same language. The source must be members of a partitioned data set.

The copybook template combines the layout information provided by the source definition with additional information supplied by the user pertaining to formatting, reformatting, record selection and data creation, to produce a logical view of the data on which these functions can be performed.

In a copybook template, the field definitions (start position, length and type) are not editable. However, copybook templates allow you to define a number of different formats for use with data sets that contain multiple record types. Records can be identified by type within a data set and each type can be associated with a different format. This allows you to view data with different types at the same time, and to view, edit or copy these records simultaneously. Copybook templates also allow criteria editing by field or by a free format REXX selection expression.

To create a new copybook template, you begin with one or more copybooks containing field definitions that describe the record structure of your data. When you specify the copybook (or copybooks) on a panel, Z Data Tools compiles the descriptions into a template that you can save and reuse with any application data set that has the same record structure.

In a COBOL copybook, each level-01 group item describes a record type in the application data set. The elementary items in the group describe fields in the record type. For example, the following copybook describes the record structure of an application data set that contains two record types, ORDERS and ITEM:

01 ORDERS.
   05 ORDER-ID        PIC X(5).
   05 CUSTOMER-ID     PIC X(5).
   05 ORDER-DATE.
      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.

The ORDERS records contain five fields: ORDER-ID, CUSTOMER-ID, ORDER-YEAR, ORDER-MONTH and ORDER-DAY. The ITEM records contain three fields: PRODUCT-ID, QUANTITY and UNIT-COST.

PL/I copybooks are similar to COBOL copybooks, in that the major structures (level-1 names) describe record types and elementary names describe fields:

DECLARE 1 ORDER,
          2 ORDERID       CHAR(9),
          2 CUSTOMERID    CHAR(5),
          2 ORDERDATE,
            3 ORDERYEAR   CHAR(4),
            3 ORDERMONTH  CHAR(2),
            3 ORDERDAY    CHAR(2);
DECLARE 1 ITEM,
          2 PRODUCTID     CHAR(9),
          2 QUANTITY      BIN(15),
          2 UNITCOST      BIN(31);

HLASM copybooks are similar to COBOL copybooks, in that the major structures (DSECT names) describe record types and elementary names describe fields:

ORDER      DESCT
ORDERID    DS  CL9
CUSTOMERID DS  CL5
ORDERDATE  DS  0CL8
ORDERYEAR  DS  CL4
ORDERMONTH DS  CL2
ORDERDAY   DS  CL2
ITEM       DESCT
PRODUCTID  DS  CL9
QUANTITY   DS  H
UNITCOST   DS  F

For information about coding copybooks, see the IBM COBOL Language Reference, IBM VisualAge PL/I Language Reference, or the HLASM V1R6 Language Reference.

Related topics