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
 

 

Redefining 9(Numeric) to X(Alphanumeric) and again to 9

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
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

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: 1592

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: 106
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

New User


Joined: 08 Mar 2005
Posts: 54
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

Active User


Joined: 06 Jan 2004
Posts: 247
Location: Hyderabad

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: 106
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

Active User


Joined: 06 Jan 2004
Posts: 247
Location: Hyderabad

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
David P

Active User


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

PostPosted: Thu Apr 14, 2005 2:03 pm    Post subject:
Reply with quote

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

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Thu Apr 14, 2005 3:53 pm    Post subject:
Reply with quote

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

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

New User


Joined: 04 Apr 2005
Posts: 20
Location: Mysore

PostPosted: Thu Apr 14, 2005 4:34 pm    Post subject:
Reply with quote

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

New User


Joined: 25 Mar 2005
Posts: 3

PostPosted: Fri Apr 15, 2005 1:39 pm    Post subject:
Reply with quote

hi anu,
i think that spaces also of alphanumeric type, while so it produces the same result. Lets check it out.
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 Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


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