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
 

 

If the size of redefining field greater than redefined

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: If the size of redefining field greater than redefined
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    Post subject:
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: 1203
Location: India

PostPosted: Thu Mar 17, 2005 11:16 pm    Post subject:
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    Post subject: Re: If the size of redefinin field is greater
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 1203
Location: India

PostPosted: Sat Mar 19, 2005 8:22 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    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 SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am
No new posts 2 byte YEAR from Y'DATE2' field tecnokrat DFSORT/ICETOOL 2 Tue Feb 07, 2017 12:05 pm
No new posts Sort two file having same field, one ... himanshu malik DFSORT/ICETOOL 7 Thu Feb 02, 2017 10:09 am


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