COBOL Renames Clause with Examples

COBOL Renames clause is used to regroup the elementary data items and gives them an alternative name. This is a logical grouping of the elementary data items which are defined in a sequential order.It is useful for renaming by overlapping elementary elements.66 Level number is used for defining it.

– 01 , 77 levels can not be used for renames.

Redefines with Renames:
– It can be used on redefined variables but that should not end within the redefined variable.

This gives an error because ww-v2 and ww-v3-1 + ww-v3-2 has same length.

IGYDS0014-S “RENAMES” object “WW-V3-2” was contained within, or had a common leftmost byte with, object “WW-V2”. The “RENAMES” clause was discarded.

66 WW-RNM1 RENAMES WW-V1 THRU WW-V3-2. It works because renaming starts from ww-v1.

It works in below case as well, here I increased the length of ww-v3-2.

Renames with OCCURS ->
In Example-1, any group variable from ww-v2 to ww-v3-4 should not contain occurs.
So WW-V1, WW-V2, WW-V3 & WW-V4 should not contain occurs.
But ww-v3-1 to ww-v3-4 can contain occurs BUT should not contain Ocuurs depending on Clause.

Leave a Reply

Your email address will not be published. Required fields are marked *