WebSphere logo Classic Federation Server for z/OS, Version 9.1
WebSphere logo Classic Replication Server for z/OS, Version 9.1
WebSphere logo Classic Data Event Publisher for z/OS, Version 9.1
WebSphere logo Data Integration Classic Connector for z/OS, Version 9.1


Array definition examples

Use these examples to help you understand COBOL and PL/I array definitions, so that you can map your tables and views correctly.

When you create relational tables or views on your data server, Classic Data Architect uses data definitions that are contained in COBOL copybooks or PL/I include files to generate data definition language (DDL). You then run the DDL on your data server to create user tables in the metadata catalogs.

COBOL examples

Example: COBOL definition of a fixed-length array.

The DEPENDENTS-ARRAY clause defines an array structure of four fields that has a fixed length and repeats exactly 20 times. You can use the NULL-IS parameter in a CREATE TABLE or CREATE VIEW statement to specify a null value for empty array instances.
01  EMPLOYEE-RECORD.
    05 EMP-LAST-NAME               PIC X(20).
    05 EMP-FIRST-NAME              PIC X(20).
    05 EMPID                       PIC 9(9).
....
    05 DEPENDENTS-ARRAY OCCURS 20 TIMES
       10 DEP-ID                    PIC 9(9).
       10 DEP-NAME                  PIC X(20).
       10 DEP-DOB                   PIC 9(6).
       10 DEP-RELATIONSHIP-TO-EMPL  PIC X.

Example: COBOL definition of a variable-length array.

The array can appear 1 to 20 times, depending on the value of the variable NUMBER-OF-DEPENDENTS specified in the DEPENDING ON clause.
01  EMPLOYEE-RECORD.
    05 EMP-LAST-NAME PIC X(20).
    05 EMP-FIRST-NAME PIC X(20).
    05 EMP-ID PIC 9(9).
....
    05 NUMBER-OF-DEPENDENTS PIC 9(4) COMP.
    05 DEPENDENTS-ARRAY OCCURS 1 TO 20 TIMES
       DEPENDING ON NUMBER-OF-DEPENDENTS.
       10 DEP-SSN PIC 9(9).
       10 DEP-NAME PIC X(20).
       10 DEP-DOB PIC 9(6).
       10 DEP-GENDER PIC X.

Example: CREATE TABLE statement based on the COBOL copybook.

The DDL maps a subset of the data items:

CREATE TABLE CAC.EMPL .....
(
  EMP_ID SOURCE DEFINITION
   DATAMAP OFFSET 40 LENGTH 9 DATATYPE C
   USE AS CHAR(9),
  NUMBER_OF_DEPENDENTS SOURCE DEFINITION
   DATAMAP OFFSET 49 LENGTH 2 DATATYPE H
   USE AS SMALLINT,  
 BEGINLEVEL 1 OFFSET 51 LENGTH 36 OCCURS 20
   DEPENDING ON COLUMN NUMBER_OF_DEPENDENTS,
  DEP_ID SOURCE DEFINITION
   DATAMAP OFFSET 0 LENGTH 9 DATATYPE C
   USE AS CHAR(9),
  DEP_NAME SOURCE DEFINITION
   DATAMAP OFFSET 9 LENGTH 20 DATATYPE C
   USE AS CHAR(20),
 ENDLEVEL 1
)

PL/I samples

Example: A PL/I include file that describes an employee record.

The DIMENSION (DIM) attribute defines a fixed-length array structure that repeats exactly 20 times. You can use the NULL-IS parameter in a CREATE TABLE or CREATE VIEW statement to specify a null value for empty array instances.
DCL 1 EMPLOYEE_RECORD BASED,
      5 EMP_LAST_NAME CHAR(20),
      5 EMP_FIRST_NAME CHAR(20), 
      5 EMPID   PIC '(9)9',
....
      5 DEPENDENTS_ARRAY DIM(20)
        10 DEP_ID PIC '(9)9', 
        10 DEP_NAME CHAR(20),
        10 DEP_DOB PIC '(6)9', 
        10 DEP_RELATIONSHIP_TO_EMPL CHAR(1);

Example: A PL/I include file that defines a variable-length array.

The PL/I DIM attribute specifies that the number of dependents determines the number of array instances. The array can appear 1 to 20 times, depending on the value of the variable NUMBER_OF_DEPENDENTS specified in the REFER attribute.
DCL 1 EMPLOYEE_RECORD BASED,
      5 EMP_LAST_NAME CHAR(20),
      5 EMP_FIRST_NAME CHAR(20),
      5 EMPID   PIC '(9)9',
....
      5 NUMBER_OF_DEPENDENTS BIN FIXED(15),
      5 DEPENDENTS_ARRAY DIM(N1 REFER(NUMBER_OF_DEPENDENTS)),
        10 DEP_ID PIC '(9)9',
        10 DEP_NAME CHAR(20),
        10 DEP_DOB PIC '(6)9',
        10 DEP_RELATIONSHIP_TO_EMPL CHAR(1);

Example: CREATE TABLE statement based on a PL/I include file.

The DDL maps a subset of the data items:

The data server calculates the number of array instances automatically when you run the DDL on the data server to create the table. Nevertheless, restrictions on mapping columns that appear in the structure after variable-length arrays still apply.

CREATE TABLE "AA"."EMPLOYEE_RECORD" DBTYPE SEQUENTIAL
	DS "D"
(

	"EMPID" SOURCE DEFINITION
		DATAMAP OFFSET 40 LENGTH 9
		DATATYPE C
		USE AS CHAR(9),
	"NUMBER_OF_DEPENDENTS" SOURCE DEFINITION
		DATAMAP OFFSET 49 LENGTH 2
		DATATYPE H
		USE AS SMALLINT,
	BEGINLEVEL 1 OFFSET 51 LENGTH 0
		OCCURS DEPENDING ON COLUMN "NUMBER_OF_DEPENDENTS",
	"DEP_ID" SOURCE DEFINITION
		DATAMAP OFFSET 0 LENGTH 9
		DATATYPE C
		USE AS CHAR(9),
	"DEP_NAME" SOURCE DEFINITION
		DATAMAP OFFSET 9 LENGTH 20
		DATATYPE C
		USE AS CHAR(20),
	ENDLEVEL 1	);
Related concepts
Record arrays
Performance considerations with multiple record arrays
Record array definitions for federation and change capture


Feedback

Update icon Last updated: 2007-10-09