View previous topic :: View next topic
|
Author |
Message |
rashmik
New User
Joined: 09 Mar 2007 Posts: 2 Location: mysore
|
|
|
|
[/b]
hi all
i have confusions in using redefines clause. in some cobol books it was explanined that redefined item should be of the same size of the redefining item. but currently i think there is no such restrictions. can anyone of you tell me more about these things? and can i have some reading docs on this subject? |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Quote: |
i think there is no such restrictions. |
This is correct, however you will receive a compiler warning when you do such thing.
For Reading material, I would suggest searching on forum. You will find several threads on this topic. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Rashmi,
Quote: |
there is no such restrictions |
The redefined variable should be less than or equal to the original item. But remeber it cant be more than original item length. This is the only restriction you have when you redefine an item. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Murali,
Quote: |
The redefined variable should be less than or equal to the original item. But remeber it cant be more than original item length. This is the only restriction you have when you redefine an item. |
Partially true.
This statement doesnt hold good for 01 level variables. There is no such restriction on them.
Below declaration is perfectly legal.
Code: |
01 VAR1 PIC X(100).
01 VAR2 REFINIES VAR1 PIC X(200). |
|
|
Back to top |
|
|
venosol Warnings : 1 New User
Joined: 16 Nov 2006 Posts: 43 Location: Bangalore
|
|
|
|
agkshirsagar wrote: |
Murali,
Quote: |
The redefined variable should be less than or equal to the original item. But remeber it cant be more than original item length. This is the only restriction you have when you redefine an item. |
Partially true.
This statement doesnt hold good for 01 level variables. There is no such restriction on them.
Below declaration is perfectly legal.
Code: |
01 VAR1 PIC X(100).
01 VAR2 REFINIES VAR1 PIC X(200). |
|
Consider this 01 WS-NAME REDEFINES WS-DUP-NAME
Governing rules :
1. In this WS-NAME should not exceed WS-DUP-NAME if we are using in 01 level. But in other levels the size must the same.
2. Value clause should not be used in REDEFINES caluse or to its subordinates.
3. This clause must not be used for levels 66 and 88
4. REDEFINES clause must not used for record levels
5. Multiple redefination is possible. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Quote: |
1. In this WS-NAME should not exceed WS-DUP-NAME if we are using in 01 level. But in other levels the size must the same. |
Dear Venu,
Somebody taught you this or you read from some 'non standard' or 'dark age' book ?
Give it a try and find out yourself.
Code: |
01 PRT-CNTER PIC X(300) .
01 TOTAL-READ REDEFINES PRT-CNTER PIC X(200). |
And what do you mean by this?
Quote: |
REDEFINES clause must not used for record levels |
I wonder how you are so confident with each of your posts.
I am out of this thread now. |
|
Back to top |
|
|
venosol Warnings : 1 New User
Joined: 16 Nov 2006 Posts: 43 Location: Bangalore
|
|
|
|
agkshirsagar wrote: |
Quote: |
1. In this WS-NAME should not exceed WS-DUP-NAME if we are using in 01 level. But in other levels the size must the same. |
Dear Venu,
Somebody taught you this or you read from some 'non standard' or 'dark age' book ?
Give it a try and find out yourself.
Code: |
01 PRT-CNTER PIC X(300) .
01 TOTAL-READ REDEFINES PRT-CNTER PIC X(200). |
And what do you mean by this?
Quote: |
REDEFINES clause must not used for record levels |
I wonder how you are so confident with each of your posts.
I am out of this thread now. |
I got it from a book.
Your program is correct. It is according to the rule which I mentioned already. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Back to the initial post
Quote: |
i have confusions in using redefines clause. in some cobol books it was explanined that redefined item should be of the same size of the redefining item. but currently i think there is no such restrictions. can anyone of you tell me more about these things? and can i have some reading docs on this subject?
|
It is a very good idea to ensure both are the same length (i.e. should be). The compiler will permit a short "field" to redefine a longer one. IMHO, this is another thing that while we can do, it is better not to. If both are the same length, it may help someone who must work with the code later (and FILLERs are free).
There are several good cobol books, but if you buy one or borrow one from a library, make sure it is for the environment you work in. There is a lot of MicroFocus info available, but the only places i've used MicroFocus is on unix or win-based platforms. If you look for Murach as the publisher, they have "Murach's Structured COBOL" which is mainframe-based.
You will also want to download the COBOL manuals linked to from this forum. You only need the ones for your environment.
Please let us know if you'd like any other info |
|
Back to top |
|
|
sachin_star3 Warnings : 1 New User
Joined: 30 Sep 2006 Posts: 78 Location: pune
|
|
|
|
Hi rashmik
Redefine is use for the consevation memory
redefine is clause and it mostly use in cobol program
this is poweful tool
i give you example how it use the same memory location
ID-DIVISION.
PROGRAM-ID . EEE.
DATA DIVISION
WORKING-STORAGE SECTION.
77 A PIC X(5)
77 B REDEFINES A X(4)
SO YOU GIVE ANY VALUE TO A AND B AND THEN DISPLAY A AND B THE THE RESULT OF ARE SAME BECAUSE BOTH USE SAME MEMORY LOCATION.
RULES WHEN REDEFINE USE WITH LEVEL
:
1) 77 LEVEL: THE SECOND ITEM YOU CAN REDEFINE MEMORY IS EQUAL TO SAME PREVIOS OR LESS THEN BUT NOT GREATER THAN
EX. IN OUR ABOVE EXAMPLE YOU CAN REDEFINE B IS EQUAL TO 5 OR BELOW THE 5 CHARTER BECAUSE THE MEMORY LOCATION OF A IS 5
2) 01 TO 49 LEVEL:
BUT YOU CAN REDEFINE B HERE GREATER THEN A ALSO
SO THE WHEN YOU DISPLAY THE A THEN THIS EXTRA CHRACTER APPEND OR ADD TO THE LAST MEMORY LOCATION TO THE MEMORY A
3)88 LEVEL: NOT ALLOWED
4)66 LEVEL: NOT ALLOWED
FROM-
SACHIN BORASE
PUNE |
|
Back to top |
|
|
sachin_star3 Warnings : 1 New User
Joined: 30 Sep 2006 Posts: 78 Location: pune
|
|
|
|
Hi rashmik
Redefine is use for the consevation memory
redefine is clause and it mostly use in cobol program
this is poweful tool
i give you example how it use the same memory location
Code: |
ID-DIVISION.
PROGRAM-ID . EEE.
DATA DIVISION
WORKING-STORAGE SECTION.
77 A PIC X(5)
77 B REDEFINES A X(4) |
SO YOU GIVE ANY VALUE TO A AND B AND THEN DISPLAY A AND B THE THE RESULT OF ARE SAME BECAUSE BOTH USE SAME MEMORY LOCATION.
RULES WHEN REDEFINE USE WITH LEVEL
:
1) 77 LEVEL: THE SECOND ITEM YOU CAN REDEFINE MEMORY IS EQUAL TO SAME PREVIOS OR LESS THEN BUT NOT GREATER THAN
EX. IN OUR ABOVE EXAMPLE YOU CAN REDEFINE B IS EQUAL TO 5 OR BELOW THE 5 CHARTER BECAUSE THE MEMORY LOCATION OF A IS 5
2) 01 TO 49 LEVEL:
BUT YOU CAN REDEFINE B HERE GREATER THEN A ALSO
SO THE WHEN YOU DISPLAY THE A THEN THIS EXTRA CHRACTER APPEND OR ADD TO THE LAST MEMORY LOCATION TO THE MEMORY A
3)88 LEVEL: NOT ALLOWED
4)66 LEVEL: NOT ALLOWED
FROM-
SACHIN BORASE
PUNE
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Redefinition is not for memory conservation.
It is to allow the same positons in memory to have multiple names and definitions. |
|
Back to top |
|
|
|