COBOL Manual for TNS and TNS/R Programs
Creating and Compiling HP COBOL Source
Programs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
22-26
Using Data Definition Language (DDL)
Data Declaration (COPY) Library
Example 22-4 shows the data declaration (COPY) library that the DDL compiler
produces from the input shown in Example 22-3
. The DDL compiler has assigned (or
reassigned) appropriate level numbers—for example:
Example 22-3. Input to the DDL Compiler
DEFINE NAME.
02 LAST-NAME PIC X(15).
02 MIDDLE-INITIAL PIC X(1).
02 FIRST-NAME PIC X(15).
END
DEFINE ADDRESS.
02 STREET-NUMBER PIC X(6).
02 STREET-NAME PIC X(25).
02 FLAT-NUMBER PIC X(8).
02 MUNICIPALITY PIC X(25).
02 STATE-OR-PROVINCE PIC X(25).
02 NATION PIC X(25).
02 POSTAL-CODE PIC X(11).
END
DEFINE NAME-AND-ADDRESS.
05 NAME TYPE *.
05 ADDRESS TYPE *.
END
RECORD PERSON-RECORD. FILE IS "folks" Entry-Sequenced.
02 NAME-AND-ADDRESS TYPE *.
02 OCCUPATION-NUMBER PIC 9(6).
02 OCCUPATION-NAME PIC X(35).
02 EMPLOYER-NAME PIC X(35).
02 EMPLOYER-ADDRESS TYPE address.
KEY "PN" IS NAME-AND-ADDRESS.NAME.
KEY "EN" IS EMPLOYER-NAME.
END
Data Item Level Number
NAME 01
STREET-NUMBER in the record ADDRESS 02
STREET-NUMBER in the record NAME-AND-ADDRESS 03
STREET-NUMBER in the record PERSON-RECORD 04