Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Regarding the alphanumeric data type

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
k.pavankumar

New User


Joined: 22 May 2006
Posts: 8

PostPosted: Mon May 22, 2006 5:28 pm    Post subject: Regarding the alphanumeric data type
Reply with quote

Hi

Is it possible to use the Alphanumeric declared variable as a target for the Compute statement.

Advance Thanks. Please Reply
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Mon May 22, 2006 6:02 pm    Post subject:
Reply with quote

Pavan,

I dont think so.
Back to top
View user's profile Send private message
vijayamadhuri

Active User


Joined: 06 Apr 2005
Posts: 180

PostPosted: Tue May 23, 2006 12:13 am    Post subject: hello
Reply with quote

It should be elementary numeric item(s) or elementary numeric-edited
items.
Back to top
View user's profile Send private message
Bharanidharan

New User


Joined: 20 Jun 2005
Posts: 86
Location: Chennai, India

PostPosted: Tue May 23, 2006 11:18 am    Post subject: Re: hello
Reply with quote

I believe you can use numeric data to be stored in alpha variable, because logically target is nothing but a storage; you will face bomb only when you try to access that storage.
Since the very purpose of declaring an alpha is for non-computational purposes, I don't think this usage would be commonplace.
Back to top
View user's profile Send private message
humpty
Warnings : 1

New User


Joined: 01 May 2005
Posts: 23

PostPosted: Thu May 25, 2006 11:11 am    Post subject:
Reply with quote

hi pavan,

let me inform you that Alphanumeric type can contain alphabetic as well as numeric values.

but the limitation for the compute verb is that it is restricted only for numeric data items. so if you cannot target alphanumeric element compute verb.

thanks
Back to top
View user's profile Send private message
humpty
Warnings : 1

New User


Joined: 01 May 2005
Posts: 23

PostPosted: Thu May 25, 2006 11:14 am    Post subject:
Reply with quote

hi pavan,

The COMPUTE statement assigns the value of an arithmetic expression to one or more data items. With the COMPUTE statement, arithmetic operations can be combined without the restrictions on receiving data items imposed by the rules for the ADD, SUBTRACT, MULTIPLY, and DIVIDE statements. When arithmetic operations are combined, the COMPUTE statement may be more efficient than the separate arithmetic statements written in a series.
Back to top
View user's profile Send private message
gskulkarni

New User


Joined: 01 Mar 2006
Posts: 70

PostPosted: Thu May 25, 2006 11:22 am    Post subject:
Reply with quote

I don't think humpty's reply is in line with the original question.
It was a simple query of whether or not one can do this:
Code:
01 WS-AMOUNT pic x(05) value '34560'

COMPUTE WS-RESULT = WS-AMOUNT * 5.


The answer is NO.
You will get error at compilation time as follows:

Code:
IGYPA3074-S   "WS-AMT-1 (ALPHANUMERIC)" was not numeric, but was a sender in an arithmetic expression.  The statement was discarded.
Back to top
View user's profile Send private message
manisha-s
Warnings : 1

New User


Joined: 22 May 2006
Posts: 13

PostPosted: Thu May 25, 2006 11:26 am    Post subject: re:Regarding the alphanumeric data type
Reply with quote

compute w=u
is valid statement bcoz it is similar to move u to w.
n we can move anything to alphanumeric variable .
so i think it is possible to target an alphanumeric variable in a compute statement.
Back to top
View user's profile Send private message
gskulkarni

New User


Joined: 01 Mar 2006
Posts: 70

PostPosted: Thu May 25, 2006 11:33 am    Post subject: Re: re:Regarding the alphanumeric data type
Reply with quote

manisha-s wrote:

so i think it is possible to target an alphanumeric variable in a compute statement.


Apparently not in all of the 'compute's.
See my post above.
Back to top
View user's profile Send private message
manisha-s
Warnings : 1

New User


Joined: 22 May 2006
Posts: 13

PostPosted: Thu May 25, 2006 12:27 pm    Post subject: re:Regarding the alphanumeric data type
Reply with quote

hi gskulkarni
i suppose the question is
"Is it possible to use the Alphanumeric declared variable as a target for the Compute statement. "

what u did ? u tried to make computations over the alphanumeric values thats not possible .
but still u can target anything to alphanumeric value .
u plz try this thing .

a pic x(3) value "234".
b pic x(3).
compute b=a.
Back to top
View user's profile Send private message
humpty
Warnings : 1

New User


Joined: 01 May 2005
Posts: 23

PostPosted: Thu May 25, 2006 12:48 pm    Post subject:
Reply with quote

hi gskulkarni,

i fully agree with manisha-s.
bottom line answer is that you cannot manipulate any alphanumeric
data item with COMPUTE verb, instead you can do the same with numeric data types only.

thanks.
Back to top
View user's profile Send private message
gskulkarni

New User


Joined: 01 Mar 2006
Posts: 70

PostPosted: Thu May 25, 2006 1:35 pm    Post subject:
Reply with quote

Although your statement compute c=u will work i believe that it is more of a "MOVE" statement equivalent rather than arithmetic operation.

I stand corrected here.
manisha's reply comput c=u may be insuffiencient in the context where question is if alphanumeric could be target for computational statement.

Code:
01 WS-AMT-1      PIC 9(05).     - This is the field to be used for arithmetic
01 WS-RESULT-AMT PIC X(05).  - this is the target field after arithmetic on above variable


I have executed below code:
Code:
MOVE 34560 TO    WS-AMT-1.
DISPLAY 'WS-AMT-1 = ' WS-AMT-1.
COMPUTE WS-RESULT-AMT = WS-AMT-1 * 2.
DISPLAY 'WS-RESULT-AMT = ' WS-RESULT-AMT


And it has given following response.

Code:
IGYPA3146-S   Receiving operand "WS-RESULT-AMT (ALPHANUMERIC)" of an arithmetic statement was neither numeric nor numeric-edited.  The statement was discarded.
Back to top
View user's profile Send private message
manisha-s
Warnings : 1

New User


Joined: 22 May 2006
Posts: 13

PostPosted: Thu May 25, 2006 2:42 pm    Post subject: re:Regarding the alphanumeric data type
Reply with quote

Mr. kulkarni
Kindly read urs n my answers carefully . u will get ur answer .
n one thing more that u r again doing the samething that u applied arithmetic operations on alphanumeric variable . that shudn't b done .
Back to top
View user's profile Send private message
humpty
Warnings : 1

New User


Joined: 01 May 2005
Posts: 23

PostPosted: Thu May 25, 2006 4:27 pm    Post subject:
Reply with quote

Mr. Kulkarni,

the thing what u r trying to do is called data mismatch and simply
gives SOC7 error.

.................
Back to top
View user's profile Send private message
gskulkarni

New User


Joined: 01 Mar 2006
Posts: 70

PostPosted: Thu May 25, 2006 4:34 pm    Post subject:
Reply with quote

Humpty, it will not give soc7 because the pgm itself won't get compiled as i have showed in my post.

manisha and humpty,
i am not saying what you guys are pointing out is wrong.

I accept that the alphanumeric data item can be used as target in compute statement given by manisha.

Now holoding the above sentence true, i am going ahead and saying that it is true only for one single compute statement that she has given - that is with '=' operator. And it is allowed mainly because the = operator is as good as a 'MOVE' statement. There is no other COMPUTE statement where an alphanumeric variable can be used as target.
Back to top
View user's profile Send private message
OldSystemProgrammer

New User


Joined: 12 May 2006
Posts: 7

PostPosted: Wed May 31, 2006 5:04 pm    Post subject:
Reply with quote

Hi gskulkarni!

In a numeric operation the type of operation field must be numeric. In your COMPUTE satement the type of result field is alfanumeric.
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 Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts opening a dataset after reading it fr... arunsoods DFSORT/ICETOOL 5 Wed Oct 04, 2017 3:54 pm
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Setting Font Type for XMIT satish.ms10 All Other Mainframe Topics 3 Fri Sep 15, 2017 10:01 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us