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
 
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 How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
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 Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm

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