Home » COBOL Data Layout

COBOL Data Layout

by Online Tutorials Library

COBOL – Data Layout

COBOL Layout is a description of the usage of each field and its values. The data description entries in COBOL are as follows:

  • Redefines Entries
  • Renames Entries
  • Usage Clause
  • Copybooks

Redefines Entries

The Redefines clause defines storage with various descriptions of data. If one or more data items are used at the same time, the same storage for other data items can be used.


Here, data-name1/FILLER is the REDEFINING date item. And data-name2 is REDEFINED data item.

Any number of times, a REDEFINED data item can be redefined. But it is not possible to redefine the REDEFINING item.


Here, A is the Redefined item and B and C is Redefining item.

The level numbers of redefined items and redefining items must be the same, and the level numbers cannot be 66 or 88. With a redefining object, we cannot use the VALUE clause.


COBOL Data Layout

Renames Clause

The Renames clause presents the existing data items with different names. It is used to reassemble the names of the data and to give them a new name. We may rename the new name of the data for elementary items or groups. The Renames clause is reserved at level 66.


Here, data-name-1 is the logical group’s alternative name.

Data-name-2 is a starting elementary item, and data-name-3 ends elementary data items in the basic group. The data-name-2 must be a group item if data-name-3 is not mentioned, and all elementary items under this RENAMED must be a data-name-1 item.

There are some rules for RENAMES clause:

  • RENAMES entries must be in sequential order.
  • There is no PIC clause for the 66 level numbers.
  • At the end of the group, RENAMES must be coded.
  • Level-66 can’t rename level-01, 77, 88, or another level-66 entry.
  • The OCCURS clause should not be used to RENAMED elementary items.


Let’s see one example through the COBOL program:


COBOL Data Layout

Usage Clause

The usage clause is used to define the operating system where the data is stored in the file. With level numbers 66 or 88, we can use it. If the usage clause is mentioned in a group, the same usage clause will apply to all elementary items.

The Usage clause decreases storage space, which implicitly increases the program’s efficiency.

The different options available with the usage clause are given below:


The Display clause is the default computation. The data item is stored in ASCII format in this clause and will take 1 byte for each character. The data is stored in the decimal form here. The display clause is applicable to all data types.

The memory allocation for Display usage clause is given below:

Picture Number of Bytes
9 1
X 1
A 1

Means, 1 digit/char = 1 byte

The below example calculates the number of bytes required:


We can call the COMP usage clause as BINARY or COMPUTATION. The data item is stored in a binary format. Here, data items must be an integer.

The memory allocation for the COMP Usage clause is given below:

Picture Number of Bytes
S9 TO S9 (4) 2
S9(5) to S9(9) 4
S9(9) to S9(18) 8



The data item equivalent to Float or Real is represented as a single-precision floating-point number. Data is stored internally in a hexadecimal format. The PIC clause is not accepted by COMP-1. Here one word is equal to 4 bytes.

The COMP-1 memory calculations are given below:

Picture Number of Bytes
9(16)- 1 word 4


The data item is similar to long or double and is defined as a double-precision floating-point number. Data is stored internally in a hexadecimal format. COMP-2 does not define the PIC clause. Here 2 word is equal to 8 bytes.

Picture Number of Bytes
9(32)- 2 word 8


In packed decimal format, the data item is stored. Every digit takes half a byte (1 nibble), and the sign is stored in the nibble at the right.

Picture Number of Bytes
9 ½ Byte

The Formula to calculate the number of bytes required:


A COBOL copybook is a code selection specifying the structures of the data. If we use a specific data structure in many applications, we can use copybooks instead of writing the same data structure over and over again. To add a copybook to a program, we use the COPY statement. In the Working Storage Section, we can only use the COPY statement.

The following example adds a copybook inside a COBOL program:

Here, ABC is the copybook name. The following data items in ABC copybook can be used within a program:

You may also like