COBOL Renames clause/ 66 level number

COBOL Assumed Decimal Point Data Type COBOL 77 Level Number

Advertisements


RENAMES used to regrouping the elementary items in a group item.

RENAMES will create a logical group from the group of elementary items.


Syntax:

66 data-name-1 RENAMES data-name-2
	 [THROUGH/THRU data-name-3] 

In the above syntax, data-name-1 is alternative name for the logical group.

Data-name-2 is a starting elementary item and data-name-3 is ending elementary data item in the basic group.

When data-name-3 is not specified, the data-name-2 must be a group item and all the elementary items under this RENAMED to data-name-1.


Rules:

  1. RENAMES entries must be in a sequential order.
  2. 66 level numbers didn’t have a PIC clause.
  3. RENAMES clause must be coded at the end of the group.
  4. Level-66 entry cannot rename level-01, level-77, level-88, or another level-66 entry.
  5. Elementary items with OCCURS clause should not be RENAMED.

Example:

01 A.
	05 ITEM1  PIC X(5).
	05 ITEM2  PIC X(5).
	05 ITEM3  PIC X(5).
	05 ITEM4  PIC X(5).
	05 ITEM5  PIC X(5).
	05 ITEM6  PIC X(5).
	05 ITEM7  PIC X(5).
	05 ITEM8  PIC X(5).
	05 ITEM8  PIC X(5).
	05 ITEM10 PIC X(5).
66 B RENAMES ITEM1 THRU ITEM6.

In the above example, group item A which is declared with 10 items from ITEM1 to ITEM10 will be stored on continuous memory locations

B is defined as renaming of A with 6 items from ITEM1 to ITEM6.

Here B is just a renaming variable for the data from ITEM1 to ITEM6 which uses the same memory location used by A

Below diagram can explains about how A and B represents in memory


Renames Diagram:



Example:


To display employee full details along with key details to show how the part of data item can be redefined.


Code:



Jcl:



Output:



COBOL Assumed Decimal Point Data Type COBOL 77 Level Number

Advertisements