|
|
| Author |
Message |
cmohanraj
New User
Joined: 04 Apr 2005 Posts: 15
|
|
|
|
01 ws-def
05 ws-a pic x(20)
05 ws-b pic x(50)
05 ws-c pic x(5)
05 ws-d pic x(5)
01 ws-trf redefine ws-def
05 ws-tra pic 9(80)
01 ws-shed redefine ws-def
05 ws-shda pic x(10)
05 ws-shdb pic x(70)
is this a valid redefine operation? if valid what ll happen when i initialize a data item which is alphanumeric redeifned from numeric |
|
| Back to top |
|
 |
References
|
|
 |
bsng_surru
New User
Joined: 07 Mar 2005 Posts: 16
|
|
|
|
you cant give 9(80)
compile error maxcc=12 |
|
| Back to top |
|
 |
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1508
|
|
|
|
| The reason is that there is an 18 digit limit for numeric items (31 if you use ARITH(EXTEND) in the latest compiler versions.) |
|
| Back to top |
|
 |
cmohanraj
New User
Joined: 04 Apr 2005 Posts: 15
|
|
|
|
thankyou now i have changed this code. explain me about the redefines function.
01 ws-def
05 ws-a pic x(20)
05 ws-b pic x(50)
05 ws-c pic x(5)
05 ws-d pic x(5)
01 ws-trf redefine ws-def
05 ws-tra pic 9(10)
05 ws-trb pic 9(10)
05 ws-trc pic 9(10)
05 ws-trd pic 9(10)
05 ws-tra1 pic 9(10)
05 ws-trb2pic 9(10)
05 ws-trc3 pic 9(10)
05 ws-trd4 pic 9(10)
01 ws-shed redefine ws-def
05 ws-shda pic x(10)
05 ws-shdb pic x(70)
is this a valid redefine operation? if valid what ll happen when i initialize a data item which is alphanumeric redeifned from numeric |
|
| Back to top |
|
 |
David P
Active User
Joined: 11 Apr 2005 Posts: 110 Location: Cincinnati Ohio
|
|
|
|
This is a valid definition. You won't get any compilation errors on this.
But when you execute the same its going to ABEND throwing a data execption.
regards,
david |
|
| Back to top |
|
 |
rsshanmugam
Active User
Joined: 08 Mar 2005 Posts: 53 Location: Chennai
|
|
|
|
| i think this not a valid redefine since ws-def is already redefined with ws-trf u cant redefine ws-def once again, the redefining variable must immediatly follow the redefining variable. |
|
| Back to top |
|
 |
anuradha
Global Moderator
Joined: 06 Jan 2004 Posts: 257
|
|
|
|
Hi rsshanmugam,
I am wondering why we can't redefine a data area more than once. The redefines structure is a valid one only. Even i doubt that initialize may cause data exception. |
|
| Back to top |
|
 |
David P
Active User
Joined: 11 Apr 2005 Posts: 110 Location: Cincinnati Ohio
|
|
|
|
Hi Anu,
Why I am saying that its going to cause a data execption is because the variable definition is of numeric type but redefinition is alphanumneric and since the memory is been assigned to numeric data type and when we try to initialize the redefined alphanumeric variable (trying to move spaces to numeric tada field in memory) it should throw a data exception.
regards,
David. |
|
| Back to top |
|
 |
sribks2005
New User
Joined: 04 Apr 2005 Posts: 20 Location: Mysore
|
|
|
|
hi David,
i tried with the small example regarding this issue.
I have given a part of that program.
i could compile and run it successfully. Why it did not throw exeption or abend while executing the program?
==============================================
WORKING-STORAGE SECTION.
01 data1.
02 data4 pic 9(2) value 45.
01 data2 redefines data1.
02 data3 pic x(2).
PROCEDURE DIVISION.
MAIN-PARA.
move spaces to data2.
if data4 = spaces
display "numeric item contained spaces"
end-if.
display "alphanumeric data2=" data2.
Stop run.
==============================================
please let us know the correct answer.
Thank you |
|
| Back to top |
|
 |
Niteshs
New User
Joined: 24 Mar 2005 Posts: 6
|
|
|
|
Can you tell what was result of this.
if data4 = spaces
display "numeric item contained spaces"
end-if.
display "alphanumeric data2=" data2.
Tx |
|
| Back to top |
|
 |
sribks2005
New User
Joined: 04 Apr 2005 Posts: 20 Location: Mysore
|
|
|
|
hi,
The result was
======================
numeric item contained spaces
alphanumeric data2="
======================
thank you |
|
| Back to top |
|
 |
sribks2005
New User
Joined: 04 Apr 2005 Posts: 20 Location: Mysore
|
|
|
|
please ignore my previous reply
hi,
The result was
======================
numeric item contained spaces
alphanumeric data2=
======================
thank you |
|
| Back to top |
|
 |
Niteshs
New User
Joined: 24 Mar 2005 Posts: 6
|
|
|
|
| can you put display as DISPLAY ""Numeric data4=" data4. |
|
| Back to top |
|
 |
sribks2005
New User
Joined: 04 Apr 2005 Posts: 20 Location: Mysore
|
|
|
|
hi Niteshs,
yes i could run the program successfully after putting
[b]DISPLAY ""Numeric data4=" data4[/b] also.
It is showing spaces.
thanks |
|
| Back to top |
|
 |
anuradha
Global Moderator
Joined: 06 Jan 2004 Posts: 257
|
|
|
|
Hi David!
| Quote: |
| Why I am saying that its going to cause a data execption is because the variable definition is of numeric type but redefinition is alphanumneric and since the memory is been assigned to numeric data type and when we try to initialize the redefined alphanumeric variable (trying to move spaces to numeric tada field in memory) it should throw a data exception. |
I mean to say even i agree with you. Am sorry, my sentence is giving different meaning there. But after seeing the test results of sribks2005, iam getting curious to test myself again. AFAIK it should give data exception. let me try at my end too regarding this.
sribks2005-- Thats a very good try. But i dont know why it is not giving data exception over there. Try to keep initialize statement instead of moving spaces to data2. Let us see what happens.. |
|
| Back to top |
|
 |
|
|