IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Regarding the alphanumeric data type


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 1208
Location: Bangalore,India

PostPosted: Mon May 22, 2006 6:02 pm
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top