View previous topic :: View next topic
|
Author |
Message |
neelesht
New User
Joined: 24 Jul 2006 Posts: 99 Location: Los Angeles
|
|
|
|
Hi All,
Can we move an alphanumeric field to numeric. If Yes, why is it possible ?
If no why not ?
Also is the other way round possible.
Thanks
-Neelesh |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
These are rules imposed by COBOL about what is possible and what is not , you can not ask "why" for each thing.
BTW. Alphanumeric to Numeric integer movement is possible.
You have to take care so that it does not give you S0C7 while doing an arithmetic operation. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Why not try it out and see what happens. |
|
Back to top |
|
|
look123
New User
Joined: 20 Apr 2007 Posts: 9 Location: pune
|
|
|
|
It is not possible.You will be get soc7 error.
01 a pic x(6) value 123awe.
01 b oic 9 (6).
Procedure division.
move a to b.
display b.
You will be get soc7 error. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Quote: |
It is not possible.You will be get soc7 error. |
Suresh,
Don' you think you have two contradictory statements here.
Regarding S0C7, I give you 101% gurantee, above program will not abend with S0C7. |
|
Back to top |
|
|
look123
New User
Joined: 20 Apr 2007 Posts: 9 Location: pune
|
|
|
|
Small correction
It is not possible.You will be get soc7 error.
01 a pic x(6) value 123awe.
01 b pic 9 (6).
01 c pic x(6).
Procedure division.
move a to b.
comput c = a+ b.
display c.
You will be get soc7 error. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
The question was moving an alpha field (a COBOL question), not an alpha value (a more fundamental question).
Of course, expat's answer is the correct one - for such a simple question, any good student who really wants to learn and remember the answer will perform the suitable variety of tests. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Are you sure that this statement will compile..
Test your program this time before posting. |
|
Back to top |
|
|
|