Showing posts with label difference between rename and redefine. Show all posts
Showing posts with label difference between rename and redefine. Show all posts

Thursday, 6 September 2012

REDEFINE & RENAME clause

What is REDEFINE clause ?

 REDEFINE means again define.


 Working-Storage Variable of your COBOL is again defined by this clause.


 Here same storage is used by other variables results in memory utilisation is good.


What is level number used for REDEFINE clause?


Level number 66 (Rename clause), 88 (condition clause), 01(Root clause) not used in defining REDEFINE clause.


REDEFINE data item should not have OCCURS clause.


Program:



W-S section:





 Program:





Output:





Can we have more than one redefine clause pointed same memory location?

For this i am writing one more REDEFINE clause which redefines STUDENT-NAME.


Here i am going to add 02 DEPT-DETAILS REDEFINES STUDENT-NAME.


Let’s see what will happen.


PROGRAM:


W-S section:



   
                                                                                                                                                                

PROCEDURE DIVISION:





  OUTPUT:





We can REDEFINE same W-S variable many times.

 What is RENAME Clause?


It used to REGROUP the W-S data items.

Uses level no. 66.

Here you can take already defined variable from your W-S section and club together in new variable.


SYNTAX:


66  Data-item Name RENAMES Data-item 1 thru data-item n.


PROGRAM:




W-S section:






 PROCEDURE DIVISION:



      
 OUTPUT:




Can we add multiple Rename clauses in one program?

YES. You can see below program for more detail.


PROGRAM:


 W-S section:






PROCEDURE DIVISION:





OUTPUT: