IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

What happens if a Variable is redefined with bigger size?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 1208
Location: Bangalore,India

PostPosted: Tue Sep 19, 2006 10:35 am
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
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: 1208
Location: Bangalore,India

PostPosted: Tue Sep 19, 2006 11:25 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
Search our Forums:

Back to Top