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

If the size of redefining field greater than redefined


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abhishekdutta

New User


Joined: 17 Mar 2005
Posts: 2
Location: bangalore

PostPosted: Thu Mar 17, 2005 8:07 pm
Reply with quote

If the size of redefinin field is greater than the filed which it is redefing then following what will happen?

Compile error.
Runtime error.
Normal execution
Back to top
View user's profile Send private message
learnmf

Active User


Joined: 14 Mar 2005
Posts: 123

PostPosted: Thu Mar 17, 2005 9:29 pm
Reply with quote

[quote]I think it will be compile error.
Quote:
Back to top
View user's profile Send private message
mcmillan

Site Admin


Joined: 18 May 2003
Posts: 1210
Location: India

PostPosted: Thu Mar 17, 2005 11:16 pm
Reply with quote

Quote:
I think it will be compile error.

This is my program, I got MAXCC=0.

Code:
 DSLIST     IBMMF.EXPERT.FORUM(SAMPLE) - 01.34              Columns 00001 00072
 Command ===>                                                  Scroll ===> 0005
 ****** ***************************** Top of Data ******************************
 000100        ID DIVISION.                                                     
 000200        PROGRAM-ID. SAMPLE.                                             
 000300        DATA DIVISION.                                                   
 000310        WORKING-STORAGE SECTION.                                         
 000320        01 A PIC 9(2) VALUE 25.                                         
 000321        01 B REDEFINES A PIC 9(4).                                       
 000330        PROCEDURE DIVISION.                                             
 000600        PRA1.                                                           
 000701            DISPLAY B.                                                   
 000704            STOP RUN.                                                   
 ****** **************************** Bottom of Data ****************************


As per ANSI-85 standards, you can redefine to higer range, only if both variables are declared in 01 level.
Back to top
View user's profile Send private message
dallasmavs

New User


Joined: 17 Mar 2005
Posts: 3

PostPosted: Thu Mar 17, 2005 11:43 pm
Reply with quote

shud not be a problem.

Eg: Variable ws-fld1 is 10 bytes and ws-fld2 redefines ws-fld1 as 20 bytes then the 10 byte memory space after ws-fld1 will be referred.

Hope it answers ur ?
Back to top
View user's profile Send private message
narena

New User


Joined: 16 Mar 2005
Posts: 18

PostPosted: Fri Mar 18, 2005 11:05 am
Reply with quote

Hi,

We can redefine a var whose size is larger than the redefined var. There is no Problem.
Back to top
View user's profile Send private message
sunnyk

New User


Joined: 20 Oct 2004
Posts: 59

PostPosted: Fri Mar 18, 2005 3:18 pm
Reply with quote

Hi all,
U can redefine a larger item only when both the variables are at 01 level.
Else it `ll give compilation error.

Thanks
Sunny
Back to top
View user's profile Send private message
kanak

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Fri Mar 18, 2005 7:45 pm
Reply with quote

i think it won't give any problem..as ia slo did this...and it was just a warning.
Back to top
View user's profile Send private message
sunnyk

New User


Joined: 20 Oct 2004
Posts: 59

PostPosted: Fri Mar 18, 2005 7:56 pm
Reply with quote

hi ,
I have tried it many times like

01 A-3.
05 A-4 PIC X(05).
05 A-5 REDEFINES A-4 PIC X(10).
*****
Then:
MOVE 'ABCD' TO A-4
MOVE A-4 TO A-5

U `ll get an error as shown below:

IGYDS1154-S "A-5" redefined a smaller item. Storage allocation may be incorrect. The program was accepted as written.

I hope u understood kanak

thanks
sunny
Back to top
View user's profile Send private message
kanak

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Sat Mar 19, 2005 6:06 pm
Reply with quote

hi sunnyk,
Sorry to bother you again as i didn't get any error.what i did is
In working storage:

01 WS-VAR1 PIC 9(02).
01 WS-VAR2 REDEFINES WS-VAR1
PIC S9(03).
In PD:

MOVE 12 TO WS-VAR1.
MOVE WS-VAR1 TO WS-VAR2.


And after compilation just warning came which is listed in COB2.SYSPRINT as

YPA3013-W Data items "WS-VAR1 (NUMERIC INTEGER)" and "WS-VAR2 (NUMERIC INTEGER)" had overlapping storage. An overlapping move will occur at execution time.

Thanks
kk
Back to top
View user's profile Send private message
mcmillan

Site Admin


Joined: 18 May 2003
Posts: 1210
Location: India

PostPosted: Sat Mar 19, 2005 8:22 pm
Reply with quote

Dear Kanak,

It's not because of your REDEFINES Clause, but for your MOVE Statement.

Your Lvalue and Rvalue of the Move statement are same, that's why you got this warning. Try the following program, you will get the same Warning Message.

Code:
****** ***************************** Top of Data ******************************
000100        ID DIVISION.                                                     
000200        PROGRAM-ID. SAMPLE.                                             
000300        DATA DIVISION.                                                   
000310        WORKING-STORAGE SECTION.                                         
000320        01 A PIC 9(2) VALUE 23.                                         
000330        PROCEDURE DIVISION.                                             
000600        PRA1.                                                           
000700            MOVE A TO A.                                                 
000701            DISPLAY "VALUE IS " A.                                       
000704            STOP RUN.                                                   
****** **************************** Bottom of Data ****************************
Back to top
View user's profile Send private message
sunnyk

New User


Joined: 20 Oct 2004
Posts: 59

PostPosted: Mon Mar 21, 2005 4:13 pm
Reply with quote

Hi kanak,


This is ur code:
01 WS-VAR1 PIC 9(02).
01 WS-VAR2 REDEFINES WS-VAR1
PIC S9(03).
In PD:

MOVE 12 TO WS-VAR1.
MOVE WS-VAR1 TO WS-VAR2.


I wrote in my message that you can redefine a larger item only when both the variables are at 01 level.

And u have redefined both WS-VAR1 and WS-VAR2 at 01 level.That`s why it`s not giving compilation error.

I hope u got it kanak.

Regds
sunny
Back to top
View user's profile Send private message
rick

New User


Joined: 18 Jun 2004
Posts: 59
Location: Chennai

PostPosted: Mon Mar 21, 2005 7:08 pm
Reply with quote

Hi,

There will not be any problem during compilation. But you may fase problem only at the run-time. There is more posibility of data loss.
Back to top
View user's profile Send private message
kanak

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Mon Mar 21, 2005 7:13 pm
Reply with quote

no as what sunny has said there will be problem even while compiling if the varibale are being defined not in 01 level.
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
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 Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
Search our Forums:

Back to Top