Summary -

In this topic, we described about the below sections -

Specifies the alignment of an elementary item on a natural boundary in storage. SYNC and SYNCHRONIZED are equal and same meaning. The SYNCHRONIZED clause is never required but can improve performance of binary items used in arithmetic on some systems.

If SYNCHRONIZED clause specified for level-01 group items, every elementary item within the group item is synchronized. The compiler aligns all level-01 entries on a doubleword boundary. The length of an elementary item is not affected by the SYNCHRONIZED clause.

Syntax -

Synchronized Syntax

LEFT -

Specifies the elementary item is to be begins at the left character position of the natural boundary.

RIGHT -

Specifies the elementary item is to be begins at the right character position of the natural boundary.

Slack Bytes -

The memory bytes that are left unused between the memory allocations are called slack bytes. The binary items that are not on their natural boundaries, the compiler inserts slack bytes within a record to ensure all SYNCHRONIZED items are on their proper boundaries.

The slack bytes normally added before the SYNCHRONIZED elementary item to start it from boundary. There are two types of slack bytes -

  • Slack bytes within records
  • Slack bytes between records

Slack bytes within records -

Unused character positions added before each synchronized item in the records. For example -

01 STUDENT.
   05 STUDENT-NO       PIC 9(02).
   05 STUDENT-NAME     PIC X(12) SYNC.
   05 STUDENT-GRADE    PIC 9(02) SYNC.
   05 STUDENT-CLASS    PIC X(03).

The compiler inserts the slack bytes after STUDENT-NO to start the next item STUDENT-NAME from the boundary (i.e. full word boundary). The declaration becomes after slack bytes is -

01 STUDENT.
   05 STUDENT-NO       PIC 9(02).
  [05 SLACK-BYTES      PIC XX.  INSERTED BY COMPILER]
   05 STUDENT-NAME     PIC X(12) SYNC.
   05 STUDENT-GRADE    PIC 9(02) SYNC.
   05 STUDENT-CLASS    PIC X(03).

The below diagram represents the memory allocation along with slack bytes -

Slack bytes within record

Slack bytes between records -

Unused character positions added between blocked logical records. For example -

01 STUDENT.
  03 STUDENT-D OCCURS 2 TIMES.
   05 STUDENT-NO       PIC 9(02).
   05 STUDENT-NAME     PIC X(12) SYNC.
   05 STUDENT-GRADE    PIC 9(02) SYNC.
   05 STUDENT-CLASS    PIC X(03).

The compiler inserts the slack bytes (3) after record STUDENT-D to start the next record STUDENT-D from the boundary (i.e. full word boundary). The declaration becomes after slack bytes is -

01 STUDENT.
  03 STUDENT-D OCCURS 2 TIMES.
   05 STUDENT-NO       PIC 9(02).
   05 STUDENT-NAME     PIC X(12) SYNC.
   05 STUDENT-GRADE    PIC 9(02) SYNC.
   05 STUDENT-CLASS    PIC X(03).
  [05 SLACK-BYTES      PIC X(03).  INSERTED BY COMPILER]

The below diagram represents the two-records memory allocation along with slack bytes -

Slack bytes between record