View previous topic :: View next topic
|
Author |
Message |
purushoth_jp
New User
Joined: 12 Dec 2004 Posts: 22
|
|
|
|
hi all
can anyone explain me what is the use of renames clause.
regards
purushoth |
|
Back to top |
|
|
ovreddy
Active User
Joined: 06 Dec 2004 Posts: 211 Location: Keane Inc., Minneapolis USA.
|
|
|
|
Hi,
RENAMES in cobol is used to declare a new data item in terms of an existing data item. The level number should be 66.
Eg: 01 MY-REC.
02 X PIC 9(3).
02 Y PIC X(10).
02 Z PIC X(20).
I want to declare a U-REC with same structure as MY-REC then
66 U-REC RENAMES MY-REC.
This is equilant to declaring U-REC with same structure of MY-REC.
If you want to declare U-REC with a part of MY-REC then u can declare it as...
66 U-REC RENAMES X THROUGH Y.
It means your record will contain only X,Y sub data items.
Bye,
Reddy. |
|
Back to top |
|
|
muthukumarapandian
New User
Joined: 08 Oct 2004 Posts: 42 Location: chennai, india
|
|
|
|
Hi reddy,
It is not possible to use renames in level numbers other than 02 to 49. |
|
Back to top |
|
|
anuradha
Active User
Joined: 06 Jan 2004 Posts: 247 Location: Hyderabad
|
|
|
|
Hi muthukumarapandian
Quote: |
It is not possible to use renames in level numbers other than 02 to 49. |
I couldn't get you what you are saying? Do you mean to say we can use renames only with level numbers 02-49.
Renames should be used only with level number 66. |
|
Back to top |
|
|
muthukumarapandian
New User
Joined: 08 Oct 2004 Posts: 42 Location: chennai, india
|
|
|
|
Hi ,
I am telling that u can rename the elements declared in 02 to 49 level. |
|
Back to top |
|
|
mcmillan
Site Admin
Joined: 18 May 2003 Posts: 1210 Location: India
|
|
|
|
But the question is: "What's the use of Renames Clause"
The uses of RENAMES Clause:
1. To create a new group from one or more existing groups
2. To create an alias name
But the main purpose of RENAMES Clause, it can be used in DISPLAY statement effectively.
For example, assume that I have a group with 5 subjects. I want to display the second, third and forth subjects only.
Code: |
01 MARKS.
02 MARK1 PIC 99.
02 MARK2 PIC 99.
02 MARK3 PIC 99.
02 MARK4 PIC 99.
02 MARK5 PIC 99.
So I have to use DISPLAY M2, M3, M4. (if NO renames)
With RENAMES, I can do this like:
66 SUBMARKS RENAMES MARK2 THRU MARK4.
Now I can say: DISPLAY SUBMARKS.
(Assume the efficiency if you have 100 fields in that group)
|
|
|
Back to top |
|
|
|