This tutorial on how to read
a COBOL layout was written specifically for our customers who have had a conversion
performed at Disc Interchange and have received a COBOL layout with the data.
It is intended to give you enough information to read most
simple layouts. It does not cover all topics or everything you would
find in a complex layout, and it is intended to explain COBOL layouts only
so you can use your converted data, not so you can write COBOL programs.
This article begins here: Reading COBOL Layouts where you will also find a topic index. |
Contents of this section:
That's our business! |
Let's start with a simple layout and add features as we go.
01 CUSTOMER-RECORD. 05 LAST-NAME PIC X(15). 05 FIRST-NAME PIC X(8). 05 STREET-ADDRESS PIC X(20). 05 CITY PIC X(17). 05 STATE PIC XX. 05 ZIP-CODE PIC 9(5). 05 FILLER PIC X(10).Notice a few things:
01 CUSTOMER-RECORD. 05 CUSTOMER-NAME. 10 LAST-NAME PIC X(15). 10 FIRST-NAME PIC X(8). 05 STREET-ADDRESS PIC X(20). 05 CITY PIC X(17). 05 STATE PIC XX. 05 ZIP-CODE PIC 9(5). 05 FILLER PIC X(10).This record has exactly the same field positions as the previous layout. The group CUSTOMER-NAME at the 05 level is composed of all the fields subordinate to it, down to the next 05 field. i.e., it's composed of LAST-NAME and FIRST-NAME. CUSTOMER-NAME is a group, not a field, and therefore does not have (and cannot have) a PIC, and the line that reads "05 CUSTOMER-NAME" does not, by itself, reserve any space in the record.
Groups are handy for a number of reasons. You can operate on all the fields in a group by referring to the name of the group. If you reference CUSTOMER-NAME in the above layout, it will implicitly include all lower levels, LAST-NAME and FIRST-NAME in this case.
You can also have groups within a group. The following example, used in part 1 of this article is an example:
01 MAILING-RECORD. 05 COMPANY-NAME PIC X(30). 05 CONTACTS. 10 PRESIDENT. 15 LAST-NAME PIC X(15). 15 FIRST-NAME PIC X(8). 10 VP-MARKETING. 15 LAST-NAME PIC X(15). 15 FIRST-NAME PIC X(8). 10 ALTERNATE-CONTACT. 15 TITLE PIC X(10). 15 LAST-NAME PIC X(15). 15 FIRST-NAME PIC X(8). 05 ADDRESS PIC X(15). 05 CITY PIC X(15). 05 STATE PIC XX. 05 ZIP PIC 9(5).
Notice the group CONTACTS is composed of three subordinate groups: PRESIDENT, VP-MARKETING, and ALTERNATE-CONTACT. Notice, too, that the group CONTACTS contains no elementary items (fields), only groups. It could have contained elementary items, such as the following fragment:
05 CONTACTS. 10 SOURCE-OF-NAMES PIC XX. 10 PRESIDENT. 15 LAST-NAME PIC X(15). 15 FIRST-NAME PIC X(8). 10 VP-MARKETING. 15 LAST-NAME PIC X(15). 15 FIRST-NAME PIC X(8). 10 ALTERNATE-CONTACT. 15 TITLE PIC X(10). 15 LAST-NAME PIC X(15). 15 FIRST-NAME PIC X(8).
As noted in Part 1 of this article, it is legal to have multiple fields called LAST-NAME and FIRST-NAME, because they are in different groups. Although it's legal, it's still wise to make each field name unique, and you are more likely to see them prefixed or suffixed, like PRES-LAST-NAME, VP-LAST-NAME and ALT-LAST-NAME.
Next: Part 3
Redefined Fields
For more articles on data conversion, see our TechTalk Index.
Our COBOL Conversion Services |
|||||
|
Disc Interchange Service
Company, Inc.
Media Conversion Specialists
15 Stony Brook Road
Westford, MA 01886