Difference between RENAMES and REDEFINES

Question:What is the Different between REDEFINES clause and RENAMES clause in COBOL.
anonymous

Answer: The RENAMES clause does not use any extra space within the program as all it is doing is supplying a replacement name for use in a data definition attached to the program via a COPY statement. Basically it allows the same COPY statement to be used multiple times within the same program with the top level entry within the copy being given a different name for each use of the COPY. Without RENAMES there would need to be duplicates of the same COPY statement just to be able to give each a different name so as to be able to use the same definition multiple times in one program. All of this is resolved by the compiler and does not affect the size of the resultant program.

The REDEFINES clause serves a completely different purpose. It is used to provide a different data definition for the same data area. In this instance both of the names supplied are accessible to be used in the PROCEDURE DIVISION. As such the code generated by the compiler may be different depending on which of the names that is used.

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate