[an error occurred while processing this directive]
HP OpenVMS Systems Documentation |
HP COBOL
|
Previous | Contents | Index |
The descriptions of ITEM-B and ITEM-F are equivalent. Therefore, you would not expect the following sentence to change the values of ITEM-C and ITEM-D:
MOVE ITEM-B TO ITEM-F MOVE ITEM-F TO ITEM-B. |
Figure 5-6 shows how storage for the record would be allocated without and with boundary equivalence. A hyphen (-) indicates fill bytes caused by the SYNCHRONIZED clause. A plus sign (+) represents fill bytes resulting from boundary equivalence.
Figure 5-6 Storage Allocation Without and With Boundary Equivalence
Without boundary equivalence, ITEM-B occupies 8 bytes, and ITEM-F occupies 7 bytes. Moving the contents of ITEM-B to ITEM-F truncates the last byte of ITEM-D. Moving the contents of ITEM-F to ITEM-B pads the last byte of ITEM-D with a space character.
In contrast, boundary equivalence eliminates this unforeseen result. The elementary items occupy the same relative positions in each group. Therefore, the structures of ITEM-B and ITEM-F are the same, and the results of both group and elementary moves are predictable.
The following series of examples show major-minor storage allocation. The notes after each example indicate its significant features. A hyphen (-) represents fill bytes.
WORKING-STORAGE SECTION. 01 ITEM-A. 03 ITEM-B PIC X. 03 ITEM-C. 05 ITEM-D. 07 ITEM-E PIC 999 COMP SYNC. 07 ITEM-F PIC X(10). 05 ITEM-G REDEFINES ITEM-D. 07 ITEM-H PIC 9(14) COMP SYNC. 07 ITEM-I PIC XXXX. 01 ITEM-J. 03 ITEM-K. 05 ITEM-L PIC 999 COMP SYNC. 05 ITEM-M PIC X(10). 03 ITEM-N REDEFINES ITEM-K. 05 ITEM-O PIC 9(14) COMP SYNC. 05 ITEM-P PIC XXXX. |
In this example:
WORKING-STORAGE SECTION. 01 ITEM-A. 03 ITEM-B PIC X. 03 ITEM-C. 05 ITEM-D OCCURS 3 TIMES. 07 ITEM-E PIC X. 07 ITEM-F PIC 9999 COMP SYNC. 07 ITEM-G PIC X. 03 ITEM-H PIC X. |
In this example:
WORKING-STORAGE SECTION. 01 ITEM-A. 03 ITEM-B PIC X. 03 ITEM-C. 05 ITEM-D OCCURS 3 TIMES. 07 ITEM-E PIC X. 07 ITEM-F PIC 9999 COMP SYNC. 03 ITEM-H PIC X. |
In this example:
The Hewlett-Packard OpenVMS Calling Standard for the Tru64 UNIX, OpenVMS Alpha, and OpenVMS I64 systems specify Alpha natural data alignment and padding. You invoke this alignment by adding the alignment padding compiler option to the compile command line, or by using pad align directives in your source code. (Refer to the HP COBOL User Manual for additional information on the command.)
The Alpha natural alignments and field sizes that apply to elementary COBOL data fields are shown in Table 5-4.
Data Types | Alignment Starting Position | Pictures | Usages |
---|---|---|---|
8-bit character string | Byte boundary | A, X, 9, Edited | Display |
16-bit integer | Word boundary, multiple of 2 | 9(4) | COMP |
32-bit integer | Longword boundary, multiple of 4 | 9(8) | COMP |
Single-precision real | COMP-1 | ||
64-bit integer | Quadword boundary, multiple of 8 | 9(16) | COMP |
Double-precision real | COMP-2 |
These alignments and field sizes apply to elementary data items. However, they are extended to group data items at all level numbers by requiring that the alignment of the group data item conforms to the alignment of the largest natural alignment of any elementary data item that is subordinate to the group-item. Every intermediate group data item in HP COBOL is a candidate for Alpha natural alignment and padding. Every higher-level data item is padded to be the smallest multiple of the largest natural alignment of any of its subordinate elementary data items that contains the data structure. The alignment and padding can be determined in all cases by following the tree structure through as many levels as required until the elementary data item with the largest natural alignment is found. All elementary data items are aligned and sized within their data structures according to Table 5-4. <>
5.3 DATA DIVISION General Format and Rules
Function
The Data Division describes data the program creates, receives as input, manipulates, and produces as output.
FILE SECTION.
WORKING-STORAGE SECTION.
LINKAGE SECTION.
REPORT SECTION.
SCREEN SECTION. (Alpha, I64)
Data Item Type | Default Initial Value |
---|---|
Numeric | Zero |
Index-name | Occurrence number one |
Index data item | Undefined |
Tables | Undefined |
All others | Spaces |
Previous | Next | Contents | Index |