Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

What happens if a Variable is redefined with bigger size?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Vasusha

New User


Joined: 30 Jun 2006
Posts: 2

PostPosted: Tue Sep 19, 2006 10:00 am    Post subject: What happens if a Variable is redefined with bigger size?
Reply with quote

What could be the impact of the following code :

01 SHORTLIST-TABLE-DATA.
05 FILLER PIC X(28971) VALUE ALL '0'.

01 FILLER REDEFINES SHORTLIST-TABLE-DATA.
05 SHORTLIST-TABLE OCCURS 999 TIMES
INDEXED BY TBL-IDX.
10 TBL-CUST-NO PIC 9(11).
10 TBL-CUST-ORG PIC 9(3).
10 TBL-CUST-NBR PIC X(19).

It got compiled without any errors
Back to top
View user's profile Send private message

guptae

Moderator


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

PostPosted: Tue Sep 19, 2006 10:35 am    Post subject:
Reply with quote

I think in SHORTLIST-TABLE after 28971 bytes it will contain some junk data.
since it is defining smaller variable of 28971 bytes.

Correction r welcome.
Back to top
View user's profile Send private message
Vasusha

New User


Joined: 30 Jun 2006
Posts: 2

PostPosted: Tue Sep 19, 2006 11:17 am    Post subject: Re: What happens if a Variable is redefined with bigger size
Reply with quote

Actually the code was present in a production program, I was wondering if it really gives correct results. I coded a test program and it showed the output correctly.

IDENTIFICATION DIVISION.
PROGRAM-ID. GCBP01.
AUTHOR. VASUDEVA
DATE-WRITTEN. SEP, 2006.

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

INPUT-OUTPUT SECTION.
FILE-CONTROL.
*
DATA DIVISION.
FILE SECTION.
*
*
WORKING-STORAGE SECTION.
*
01 SHORTLIST-TABLE-DATA PIC X(10).
*
01 FILLER REDEFINES SHORTLIST-TABLE-DATA.
05 SHORTLIST-TABLE OCCURS 10 TIMES
INDEXED BY TBL-IDX.
10 TBL-NAME PIC X(05).
*
PROCEDURE DIVISION.
*=============================================================*
* MAIN PROGRAM
*=============================================================*
0000-MAIN.
MOVE "VASU1" TO TBL-NAME(1).
MOVE "VASU2" TO TBL-NAME(2).
MOVE "VASU3" TO TBL-NAME(3).
MOVE "VASU4" TO TBL-NAME(4).
MOVE "VASU5" TO TBL-NAME(5).
DISPLAY 'FIRST NAME IS ' TBL-NAME(1)
DISPLAY 'FIRST NAME IS ' TBL-NAME(2)
DISPLAY 'FIRST NAME IS ' TBL-NAME(3)
DISPLAY 'FIRST NAME IS ' TBL-NAME(4)
DISPLAY 'FIRST NAME IS ' TBL-NAME(5).
STOP RUN.
*

Following was the output

FIRST NAME IS VASU1
FIRST NAME IS VASU2
FIRST NAME IS VASU3
FIRST NAME IS VASU4
FIRST NAME IS VASU5

Can I confirm with this that the code in production is working fine or is it that the results may vary basing on some compile options or compiler versions
Back to top
View user's profile Send private message
guptae

Moderator


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

PostPosted: Tue Sep 19, 2006 11:25 am    Post subject:
Reply with quote

Hi Vasusha,

Code is fine.
It will work definately since you are moving values to TBL-NAME & then displaying it.
And SHORTLIST-TABLE-DATA will contain VASU1VASU2.

Hope I am clear enough
Back to top
View user's profile Send private message
HARIBHARAT

New User


Joined: 05 Jul 2006
Posts: 65
Location: pune

PostPosted: Tue Sep 19, 2006 2:42 pm    Post subject: Re: What happens if a Variable is redefined with bigger size
Reply with quote

Still I have doubt u r declare Index TBL_idx , TBL_Nmae subscript.

we can use same thing single program, what is the use index variable,

Regards

suresh
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us