Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Can a var. of larger size redefine a var. of smaller size

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
mubashshirji

New User


Joined: 14 Nov 2006
Posts: 16

PostPosted: Wed Nov 15, 2006 4:48 pm    Post subject: Can a var. of larger size redefine a var. of smaller size
Reply with quote

Consider the code below :

WORKING STORAGE SECTION.
01 var1 PIC 9(4).
01 var2 REDEFINES var1 PIC 9(8).
01 var3 PIC 9(8).
PROCEDURE DIVISION.

MOVE 100 TO var1.
MOVE 1000 TO var2.

COMPUTE var3 = var1+var2.
DISPLAY var3.
STOP RUN.

Here size of var2 is greater than var1 . Can a variable of larger size redefine a variable of smaller size and vice versa ?
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Nov 15, 2006 4:54 pm    Post subject:
Reply with quote

Hi There,

Yes. Redefines just causes both fields to start at the same location.
Back to top
View user's profile Send private message
mubashshirji

New User


Joined: 14 Nov 2006
Posts: 16

PostPosted: Wed Nov 15, 2006 5:00 pm    Post subject:
Reply with quote

Thanx a lot Ekta
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Nov 15, 2006 5:13 pm    Post subject: Re: Can a var. of larger size redefine a var. of smaller siz
Reply with quote

not sure what COBOL or mainframe you are using, but if you had at least attempted to test this, you would have received a compiler error.

read the manual, it is very clear what a redefine does; you could have answered your own question.

no way in the world that you can redefine 4 bytes into 8.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Nov 15, 2006 5:51 pm    Post subject:
Reply with quote

Hi there,

Contrary to what Dick says Redefining A with B means, A and B will start from the same location So if B is of larger length than A, it just eats into memory locations that are probably allocated to other program variables. It is advisable not to do so because we could get a SOC abend if some other variable data is overwritten so it wont give u any compilation error

Hope it will helpful
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts JES2 job size field matching Windows ... SRICOBSAS All Other Mainframe Topics 4 Tue Sep 05, 2017 5:49 pm
No new posts Easytrive Redefine vidyaa CA Products 4 Mon Jun 19, 2017 6:01 pm
No new posts Redefine SYS1.PROCLIB farhad_evan JCL & VSAM 12 Mon May 22, 2017 10:54 pm
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us