Library View Topics Framed Contents Revised Topics Previous Topic Next Topic Search Search ResultsPrevious Topic MatchNext Topic Match Notes List Notes Print Download No PDF Handheld DisconnectedHandheld ConnectedHelp

5.3.15.2 Slack Bytes within Records



For any data description that has binary items that are not on their natural boundaries, the compiler inserts slack bytes within a record to ensure that all SYNCHRONIZED items are on their proper boundaries.

Because it is important that you know the length of the records in a file, you need to determine whether slack bytes are required and, if necessary, how many the compiler will add. The algorithm the compiler uses to calculate this is as follows:

These slack bytes are added to each record immediately following the elementary data item preceding the binary item. They are defined as if they constituted an item with a level number equal to that of the elementary item that immediately precedes the SYNCHRONIZED binary item, and are included in the size of the group that contains them.

For example:


     01  FIELD-A.
       05  FIELD-B                   PICTURE X(5).
       05  FIELD-C.
         10  FIELD-D                 PICTURE XX.
        [10  SLACK-BYTES             PICTURE X.  INSERTED BY COMPILER]
         10  FIELD-E  COMPUTATIONAL  PICTURE S9(6) SYNC.

01 FIELD-L. 05 FIELD-M PICTURE X(5). 05 FIELD-N PICTURE XX. [05 SLACK-BYTES PICTURE X. INSERTED BY COMPILER] 05 FIELD-O. 10 FIELD-P COMPUTATIONAL PICTURE S9(6) SYNC.

Slack bytes can also be added by the compiler when a group item is defined with an OCCURS clause and contains within it a SYNCHRONIZED binary data item. To determine whether slack bytes are to be added, the following action is taken:

The slack bytes are inserted at the end of each occurrence of the group item containing the OCCURS clause. For example, a record defined as follows will appear in storage, as shown, in Figure 8:


     01 WORK-RECORD.
       05  WORK-CODE               PICTURE X.
       05  COMP-TABLE OCCURS 10 TIMES.
         10  COMP-TYPE             PICTURE X.
        [10  SLACK-BYTES           PIC XX.  INSERTED BY COMPILER]
         10  COMP-PAY              PICTURE S9(4)V99 COMP SYNC.
         10  COMP-HRS              PICTURE S9(3) COMP SYNC.
         10  COMP-NAME             PICTURE X(5).


                                   PICTURE 3         

Figure 8. Insertion of Slack Bytes within a Record


In order to align COMP-PAY and COMP-HRS upon their proper boundaries, the compiler has added two slack bytes within the record.

In the example previous, without further adjustment, the second occurrence of COMP-TABLE would begin one byte before a doubleword boundary, and the alignment of COMP-PAY and COMP-HRS would not be valid for any occurrence of the table after the first. Therefore, the compiler must add slack bytes at the end of the group, as though the record had been written as follows:


     01  WORK-RECORD.
       05  WORK-CODE                PICTURE X.
       05  COMP-TABLE OCCURS 10 TIMES.
         10  COMP-TYPE              PICTURE X.
        [10  SLACK-BYTES            PIC XX.  INSERTED BY COMPILER ]
         10  COMP-PAY               PICTURE S9(4)V99 COMP SYNC.
         10  COMP-HRS               PICTURE S9(3)  COMP SYNC.
         10  COMP-NAME              PICTURE X(5).
        [10  SLACK-BYTES            PIC XX.  INSERTED BY COMPILER]

In this example, the second (and each succeeding) occurrence of COMP-TABLE begins one byte beyond a doubleword boundary. The storage layout for the first occurrence of COMP-TABLE will now appear as shown in Figure 9.


   PICTURE 4         

Figure 9. Insertion of Slack Bytes between Records


Each succeeding occurrence within the table will now begin at the same relative position as the first.

Previous Topic Next Topic © Copyright IBM Corp. 1991, 1998

IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.





Return to library:   z/OS | z/OS.e | TPF | z/VSE | z/VM | IBM Hardware | IBM System z Redbooks
Glossary:   IBM terminology
Publications:   How to order publications
Readers:   Download IBM Library Reader | Download IBM Softcopy Reader | Download Adobe® Acrobat® Reader®
Library management:   Download IBM Softcopy Librarian
Contacts:   Contact z/OS


Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.