ILE COBOL Programmer's Guide

Writing the File Section and Working-Storage Section for Pointer Alignment

In the File Section and Working-Storage Section, all 01-level items and 77-level items (and some 66-level items) are placed on 16-byte boundaries.

Within a group structure, pointers must also occur on a 16-byte boundary. To ensure this, the ILE COBOL compiler adds FILLER items immediately before the pointers. To avoid these FILLER items, you should place pointers at the beginning of a group item.

If the pointer is part of a table, the first item in the table is placed on a 16-byte boundary. To ensure that all subsequent occurrences of the pointer fall on a 16-byte boundary, a FILLER item is added to the end of the table if necessary.

An example of pointer alignment follows:

 WORKING-STORAGE SECTION.
  77  APTR USAGE POINTER.
  01  AB.
      05 ALPHA-NUM PIC X(10).
      05 BPTR  USAGE PROCEDURE-POINTER.
  01  EF.
      05 ARRAY-1 OCCURS 3 TIMES.
         10 ALPHA-NUM-TWO PIC X(14).
         10 CPTR  USAGE POINTER.
         10 ALPHA-NUM-THREE PIC X(5).

In the above example, APTR is a pointer data item. The 77-level item, therefore, is placed on a 16-byte boundary. The group item AB is an 01-level item and is automatically placed on a 16-byte boundary. Within the group item AB, BPTR is not on a 16-byte boundary. To align it properly, the compiler inserts a 6-byte FILLER item after ALPHA-NUM. Finally, CPTR requires a FILLER of 2 bytes to align its first occurrence. Because ALPHA-NUM-THREE is only 5 bytes long, another 11-byte FILLER must be added to the end of ARRAY-1 to align all subsequent occurrences of CPTR.

When a pointer is defined in the File Section, and a file does not have blocking in effect, each 01-level item will be on a 16-byte boundary. If a file has blocking in effect, only the first record of a block is guaranteed to be on a 16-byte boundary. Thus pointers should not be defined for files with blocking in effect. For more information on blocking, refer to Unblocking Input Records and Blocking Output Records.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]