Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redefines and Renames 4

Status
Not open for further replies.

venkat2003

Programmer
Feb 11, 2003
8
IN
Hi,

I want to know the exact practical use of redefines class and renames class. Please give some examples.

Thanks
Venkat
 
Hi Venkat,

Redefines allows you to describe the same area of storage in differing ways, including the data format. A classic example is the solution to one of your previous posts. Ex:
Code:
01  ws-x     pic 9999.
01  ws-x-red     redefines 
    ws-x     pic xxx.

move low-values to ws-x-red
corrects the error you were getting.

Rename allows you to regroup and/or rename a field or goup of fields and optionally combine them into one field. Ex:
Code:
01  ws-x     pic 9999.
01  ws-x-ren     renames 
    ws-x.

move low-values to ws-x-ren
produces the same error that you experienced.

I've never used rename but from reading the specs I'd give it a wide berth in all but the simplest cases.

Regards, Jack.
 
A practical use for RENAMES:
Code:
01  OLD-KEY.
    05  OLD-STORE          PIC X(03).
    05  OLD-DIVISION       PIC X(03).
    05  OLD-DEPARTMENT     PIC X(03).
    05  OLD-AISLE          PIC X(03).
66  OLD-MAJOR-KEY RENAMES OLD-STORE THRU OLD-DIVISION.
66  OLD-INTER-KEY RENAMES OLD-STORE THRU OLD-DEPARTMENT.
It is true that this can be done with hierarchical group levels, but RENAMES is more elegant, and sometimes the group sturcture is in a COPYBOOK you don't want to change.
 
I haven't used RENAMES since the 70's. I think it was probably developed back when we were keypunching programs and changes were much more difficult. Before a lot of standards were developed people would define things like this:
01 OLD-KEY.
02 OLD-STORE PIC X(03).
02 OLD-DIVISION PIC X(03).
02 OLD-DEPARTMENT PIC X(03).
02 OLD-AISLE PIC X(03).

They would not leave 'gaps' in their level numbers and it made for a lot of work when it was decided later that you needed a group item including OLD-STORE and OLD-DIVISION. It meant for renumbering level numbers that wasn't always an easy task when you had to kepunch all of the changes.

We started leaving 'gaps' in our level numbers so it was easier to add those group items and also with the advent of on-line editing it became musch easier to do. I would say that we probably don't have any programs in our shop that use that feature anymore.
 
I just today used RENAMES in a new program where I wanted to "group" three fields in a copybook that I did not want to change:
[tt]
COPY PCSALES.CPY.
66 NEW-KEY RENAMES SALES-STORE-NO THRU SALES-DATE.
[/tt]
Inside the copybook:
[tt]
. . .
05 SALES-STORE-NO PIC X(02).
05 SALES-REGISTER-NO PIC X(02).
05 SALES-DATE PIC 9(06).
05 REDEFINES SALES-DATE.
10 SALES-YEAR PIC 9(02).
10 SALES-MONTH PIC 9(02).
10 SALES-DAY PIC 9(02).
. . .
[/tt]
This also illustrates the utility of REDEFINES.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top