View previous topic :: View next topic
|
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 |
|
|
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: 1592
|
|
|
|
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: 106 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
New User
Joined: 08 Mar 2005 Posts: 62 Location: Basildon
|
|
|
|
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
Active User
Joined: 06 Jan 2004 Posts: 247 Location: Hyderabad
|
|
|
|
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: 106 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
Active User
Joined: 06 Jan 2004 Posts: 247 Location: Hyderabad
|
|
|
|
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 |
|
|
David P
Active User
Joined: 11 Apr 2005 Posts: 106 Location: Cincinnati Ohio
|
|
|
|
Hi Anu,
The reason you are not getting data exception is because both the variables data1 and data2 are of alphanumeric data type. (both being group items). If you define data1 as a numeric item and redefine the same by alphanumeric (only 2 variables instead of 4) then the same run would throw a data exception.
please feel free to add your views.
david. |
|
Back to top |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
|
|
i think numeric field can contain spaces, but if u define the numeric field field as comp then u will get data exception while executing the program, at the time of compilation it won't show any error. and if the numeric field is defined just as 9(tt)...tt is any numeric value then even at the execution time it won't give abend.Just check this link...probably it will help
www.ibmmainframes.com/viewtopic.php?t=1968&highlight=
though example mention here is for comp-3 but it will be same for comp even. |
|
Back to top |
|
|
sribks2005
New User
Joined: 04 Apr 2005 Posts: 20 Location: Mysore
|
|
|
|
Quote: |
sribks2005-- Thats a very good try. But i dont know why it is giving data exception over there. Try to keep initialize statement instead of moving spaces to data2. Let us see what happens..
hi Anu,
I tried with initialize statement also.
=================================
initialize data2.
if data4 = spaces
display "numeric item contained spaces"
end-if.
display "alphanumeric data2=" data2.
==================================
but again it ran succesfully with data2 holding spaces.
Thanks,
Saraswathi
|
|
|
Back to top |
|
|
raaga21
New User
Joined: 25 Mar 2005 Posts: 3
|
|
|
|
hi anu,
i think that spaces also of alphanumeric type, while so it produces the same result. Lets check it out. |
|
Back to top |
|
|
|