Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Redefine in cobol.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
saubhik

New User


Joined: 21 Sep 2007
Posts: 14
Location: kolkata

PostPosted: Wed Apr 23, 2008 10:48 am    Post subject: Redefine in cobol.
Reply with quote

Can I redefine an X(200) field with a field of X(100) ?..plz explain with some example.
Back to top
View user's profile Send private message
References
PostPosted: Wed Apr 23, 2008 10:48 am    Post subject: Re: Redefine in cobol. Reply with quote

dick scherrer

Global Moderator


Joined: 23 Nov 2006
Posts: 7455
Location: 221 B Baker St

PostPosted: Wed Apr 23, 2008 10:54 am    Post subject:
Reply with quote

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

New User


Joined: 01 Apr 2008
Posts: 4
Location: Mysore

PostPosted: Wed Apr 23, 2008 12:08 pm    Post subject: Can I redefine an X(200) field with a field of X(100) ?..
Reply with quote

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

New User


Joined: 21 Sep 2007
Posts: 14
Location: kolkata

PostPosted: Wed Apr 23, 2008 12:37 pm    Post subject:
Reply with quote

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

Senior Member


Joined: 18 Jul 2007
Posts: 1128
Location: At my desk

PostPosted: Wed Apr 23, 2008 12:52 pm    Post subject:
Reply with quote

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

Active User


Joined: 06 Sep 2007
Posts: 298
Location: Bang,iflex

PostPosted: Wed Apr 23, 2008 12:56 pm    Post subject:
Reply with quote

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

Code:

VAR1      22
VAR2      2

that is the difference. do it with simple examples.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 Hours
Page 1 of 1