|
|
| Author |
Message |
saubhik
New User
Joined: 21 Sep 2007 Posts: 17 Location: kolkata
|
|
|
|
| Can I redefine an X(200) field with a field of X(100) ?..plz explain with some example. |
|
| Back to top |
|
 |
References
|
Posted: Wed Apr 23, 2008 10:48 am Post subject: Re: Redefine in cobol. |
 |
|
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 7915 Location: 221 B Baker St
|
|
|
|
Hello Saubhik and welcome to the forums,
| Quote: |
| Can I redefine an X(200) field with a field of X(100) ?.. |
Yes, just the way you asked the question. . .
| Code: |
01 THE-200-BYTES PIC X(200).
01 THE-100-BYTES REDEFINES THE-200-BYTES PIC X(100). |
A good habit to get into is to try this sort of thing on your own and post a question when you do not understand what happened. Usually, that will be much faster than asking and waiting for a response. |
|
| Back to top |
|
 |
shafeeqspi
New User
Joined: 01 Apr 2008 Posts: 4 Location: Mysore
|
|
|
|
Yes, we can do like that. Dick has explained it very well..
It just uses the same memory area..
It takes the first 100 bytes only, not bothering of the remaining 100...
Regards,
Shaffu |
|
| Back to top |
|
 |
saubhik
New User
Joined: 21 Sep 2007 Posts: 17 Location: kolkata
|
|
|
|
my questions was that whether we can redefine a 100 byte variable in to a 200 byte variable.
like let me know whether the below code is correct or Not -
01 THE-100-BYTES PIC X(100).
01 THE-200-BYTES REDEFINES THE-100-BYTES PIC X(200). |
|
| Back to top |
|
 |
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 1190 Location: At my desk
|
|
|
|
| saubhik wrote: |
my questions was that whether we can redefine a 100 byte variable in to a 200 byte variable.
like let me know whether the below code is correct or Not - |
Buzz, wrong,,,,That was not your original question....
| Quote: |
01 THE-100-BYTES PIC X(100).
01 THE-200-BYTES REDEFINES THE-100-BYTES PIC X(200). |
It depends, most current compilers will allow this, maybe with a warning..... |
|
| Back to top |
|
 |
vasanthkumarhb
Active User
Joined: 06 Sep 2007 Posts: 298 Location: Bang,iflex
|
|
|
|
Hi,
What Dick trying to explain is also same!!!!!
| saubhik wrote: |
my questions was that whether we can redefine a 100 byte variable in to a 200 byte variable.
like let me know whether the below code is correct or Not -
01 THE-100-BYTES PIC X(100).
01 THE-200-BYTES REDEFINES THE-100-BYTES PIC X(200). |
Why can't you read the answer properly!!!!!!!!!
in your post you are redeffinig PIC X(100) with a new variable of size PIC X(200), that is fine.
only thing you have to understand is both the variables start with the same memory means same place but the size can be changed in redefines in anyway either u can increase or decrease or else u can change the picture clause too,
the theme of REDEFINES is both the variables shares the same memory and start at the same position, also u can divde the REDEFINED variable in to elementary itms.
for example
| Code: |
WORKING-STORAGE SECTION
01 VAR1 PIC X (02).
01 var2 REDEFINES var1 PIC X(01).
.............
..........
.........
PROCEDURE DIVISION.
MOVE '22' TO VAR1.
DISPLAY 'VAR1', VAR1.
DISPLAY 'VAR2', VAR2.
.....................
.....................
.....................
......................
STOP RUN |
OUTPUT
that is the difference. do it with simple examples. |
|
| Back to top |
|
 |
|
|