View previous topic :: View next topic
|
Author |
Message |
abhishekdutta
New User
Joined: 17 Mar 2005 Posts: 2 Location: bangalore
|
|
|
|
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 |
|
|
learnmf
Active User
Joined: 14 Mar 2005 Posts: 123
|
|
|
|
[quote]I think it will be compile error.
|
|
Back to top |
|
|
mcmillan
Site Admin
Joined: 18 May 2003 Posts: 1210 Location: India
|
|
|
|
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 |
|
|
dallasmavs
New User
Joined: 17 Mar 2005 Posts: 3
|
|
|
|
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 |
|
|
narena
New User
Joined: 16 Mar 2005 Posts: 18
|
|
|
|
Hi,
We can redefine a var whose size is larger than the redefined var. There is no Problem. |
|
Back to top |
|
|
sunnyk
New User
Joined: 20 Oct 2004 Posts: 59
|
|
|
|
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 |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
|
|
i think it won't give any problem..as ia slo did this...and it was just a warning. |
|
Back to top |
|
|
sunnyk
New User
Joined: 20 Oct 2004 Posts: 59
|
|
|
|
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 |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
|
|
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 |
|
|
mcmillan
Site Admin
Joined: 18 May 2003 Posts: 1210 Location: India
|
|
|
|
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 |
|
|
sunnyk
New User
Joined: 20 Oct 2004 Posts: 59
|
|
|
|
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 |
|
|
rick
New User
Joined: 18 Jun 2004 Posts: 59 Location: Chennai
|
|
|
|
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 |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
|
|
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 |
|
|
|