Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Redefining 9(Numeric) to X(Alphanumeric) and again to 9
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL
Author Message
cmohanraj

New User


Joined: 04 Apr 2005
Posts: 15

PostPosted: Fri Apr 08, 2005 10:47 pm    Post subject: Redefining 9(Numeric) to X(Alphanumeric) and again to 9
Reply with quote

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
View user's profile Send private message
References
bsng_surru

New User


Joined: 07 Mar 2005
Posts: 16

PostPosted: Sat Apr 09, 2005 12:19 am    Post subject:
Reply with quote

you cant give 9(80)
compile error maxcc=12
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1508

PostPosted: Sat Apr 09, 2005 8:24 pm    Post subject:
Reply with quote

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
View user's profile Send private message
cmohanraj

New User


Joined: 04 Apr 2005
Posts: 15

PostPosted: Mon Apr 11, 2005 2:15 pm    Post subject:
Reply with quote

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
View user's profile Send private message
David P

Active User


Joined: 11 Apr 2005
Posts: 110
Location: Cincinnati Ohio

PostPosted: Tue Apr 12, 2005 4:28 pm    Post subject:
Reply with quote

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
View user's profile Send private message
rsshanmugam

Active User


Joined: 08 Mar 2005
Posts: 53
Location: Chennai

PostPosted: Tue Apr 12, 2005 6:49 pm    Post subject:
Reply with quote

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
View user's profile Send private message
anuradha

Global Moderator


Joined: 06 Jan 2004
Posts: 257

PostPosted: Tue Apr 12, 2005 11:53 pm    Post subject:
Reply with quote

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
View user's profile Send private message
David P

Active User


Joined: 11 Apr 2005
Posts: 110
Location: Cincinnati Ohio

PostPosted: Wed Apr 13, 2005 9:07 am    Post subject:
Reply with quote

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
View user's profile Send private message
sribks2005

New User


Joined: 04 Apr 2005
Posts: 20
Location: Mysore

PostPosted: Wed Apr 13, 2005 10:25 am    Post subject: Re: Redefining 9(Numeric) to X(Alphanumeric) and again to 9
Reply with quote

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
View user's profile Send private message
Niteshs

New User


Joined: 24 Mar 2005
Posts: 6

PostPosted: Wed Apr 13, 2005 11:15 am    Post subject:
Reply with quote

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
View user's profile Send private message
sribks2005

New User


Joined: 04 Apr 2005
Posts: 20
Location: Mysore

PostPosted: Wed Apr 13, 2005 11:57 am    Post subject: result
Reply with quote

hi,

The result was

======================
numeric item contained spaces
alphanumeric data2="
======================

thank you
Back to top
View user's profile Send private message
sribks2005

New User


Joined: 04 Apr 2005
Posts: 20
Location: Mysore

PostPosted: Wed Apr 13, 2005 11:59 am    Post subject: resuly
Reply with quote

please ignore my previous reply

hi,

The result was

======================
numeric item contained spaces
alphanumeric data2=
======================

thank you
Back to top
View user's profile Send private message
Niteshs

New User


Joined: 24 Mar 2005
Posts: 6

PostPosted: Wed Apr 13, 2005 12:09 pm    Post subject:
Reply with quote

can you put display as DISPLAY ""Numeric data4=" data4.
Back to top
View user's profile Send private message
sribks2005

New User


Joined: 04 Apr 2005
Posts: 20
Location: Mysore

PostPosted: Wed Apr 13, 2005 6:23 pm    Post subject:
Reply with quote

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
View user's profile Send private message
anuradha

Global Moderator


Joined: 06 Jan 2004
Posts: 257

PostPosted: Thu Apr 14, 2005 1:19 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe COBOL All times are GMT + 6 HoursGoto page 1, 2  Next
Page 1 of 2