View previous topic :: View next topic
|
Author |
Message |
minikaushik
New User
Joined: 03 Jul 2007 Posts: 1 Location: banglore
|
|
|
|
Everywhere its written that REDEFINES can be used for different data description entries and sizes.
and is this feasible?
01 dn1 pic a(5).
01 dn2 REDEFINES pic 9(10).
(in this data types different and we are redefining a small storage location with a bigger one)
or..............
01 dn1 pic x(10).
01 dn2 REDEFINES pic 9(5).
(in this we are redefining a large storage size with a smaller one)
Regards,
Mini kaushik |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Yes, it is feasible.
The larger redefining the smaller might raise a warning, but COBOL will take care of everything. |
|
Back to top |
|
|
nagasri83
New User
Joined: 20 May 2005 Posts: 15 Location: chennai
|
|
|
|
It is feasible, but people never do this type of coding with different lengths as the data will be truncated.
There are few chances that your program end with Data exception error (S0C7) even if you use same length.
Quote: |
Data Division.
01 dn1 pic X(5).
01 dn2 REDEFINES pic 9(5).
....
Procedure Division.
....
Move 'test1' to dn1.
Display 'Data in redefine clause: ' dn2.
....
|
After executing the above code, you program fails at Display statement as dn2 is declared as numeric but logical storage space contains alphanumeric.
If your not clear, you can try the above way and see the result. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
nagasri83 wrote: |
It is feasible, but people never do this type of coding with different lengths as the data will be truncated. |
What? Never? Truncated? I think not....... |
|
Back to top |
|
|
|