IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Redefined item should be of the same size of the redefining


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rashmik

New User


Joined: 09 Mar 2007
Posts: 2
Location: mysore

PostPosted: Thu Apr 05, 2007 12:39 pm
Reply with quote

[/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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Apr 05, 2007 12:49 pm
Reply with quote

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. icon_smile.gif
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Thu Apr 05, 2007 1:45 pm
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Apr 05, 2007 2:03 pm
Reply with quote

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. icon_smile.gif
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
View user's profile Send private message
venosol
Warnings : 1

New User


Joined: 16 Nov 2006
Posts: 43
Location: Bangalore

PostPosted: Thu Apr 05, 2007 3:31 pm
Reply with quote

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. icon_smile.gif
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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Apr 05, 2007 7:03 pm
Reply with quote

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 ? icon_smile.gif
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. icon_surprised.gif
I am out of this thread now. icon_biggrin.gif
Back to top
View user's profile Send private message
venosol
Warnings : 1

New User


Joined: 16 Nov 2006
Posts: 43
Location: Bangalore

PostPosted: Thu Apr 05, 2007 9:48 pm
Reply with quote

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 ? icon_smile.gif
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. icon_surprised.gif
I am out of this thread now. icon_biggrin.gif


I got it from a book.

Your program is correct. It is according to the rule which I mentioned already.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Apr 05, 2007 11:54 pm
Reply with quote

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 icon_smile.gif
Back to top
View user's profile Send private message
sachin_star3
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Sun Apr 08, 2007 3:02 pm
Reply with quote

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
View user's profile Send private message
sachin_star3
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 78
Location: pune

PostPosted: Sun Apr 08, 2007 3:03 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Apr 08, 2007 10:05 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
No new posts Dataset size increase on adding 1 byt... DFSORT/ICETOOL 8
No new posts TWA size of the CPLT transaction CICS 0
Search our Forums:

Back to Top