View previous topic :: View next topic
|
Author |
Message |
sudip_ghanvat
New User
Joined: 05 Apr 2007 Posts: 15 Location: pune
|
|
|
|
Hi ,
I have one quick question in mind please suggest me any solution.
working-storage section
01 a pic x(3)
01 b pic x(3) redefine a.
procedure division.
move 'ABC' to a.
display b.
add 2 to b.
display a.
display b.
so what is value of display a and display b at end of program.
thanks,
sudip ghanvat. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
You will get error with the posted code. |
|
Back to top |
|
|
sudip_ghanvat
New User
Joined: 05 Apr 2007 Posts: 15 Location: pune
|
|
|
|
But here we adding numeric value in alphanumeric field .
as per my knowledge is it ok if we add numeric value in alphnumeric field.
so if we add 2 to b(means ABC ,new value of b)
then is it possible compiler convert 2 in ASCII value???
I am confuse on it, |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Don't get confused. This code will not compile.
Why don't you give it a try..? |
|
Back to top |
|
|
sudip_ghanvat
New User
Joined: 05 Apr 2007 Posts: 15 Location: pune
|
|
|
|
OHooooo!!1
Sorry guyss
i did a big mistake..
value of b is
01 B pic 9(3)
sorry for incovinance
Thanks,
sudip |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Sudip,
Quote: |
then is it possible compiler convert 2 in ASCII value??? |
Mainframes operate on EBCDIC codes, not on ASCII.
Adding number to a numeric field which contain alphanumeric data can cause S0C7 (Data Exception).
Arithmatic instructions of mainframes are Packed decimal instructions.
So while adding zoned decimal fields, compiler will generate code for 'packing' the number to packed decimal, add and unack again for display. I this process S0C7 can occur in ADD operation, so avoid doing such additions. |
|
Back to top |
|
|
sudip_ghanvat
New User
Joined: 05 Apr 2007 Posts: 15 Location: pune
|
|
|
|
Ok,
But now my question is different actually bymistake i have put
value of 01 b pic x(3) instaed of
01 B pic 9(3)
previos field:
01 B pic x(3)
new field
01 B pic 9(3) |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
I have understood your question properly and have answered it in my last post.
Code: |
01 a pic x(3)
01 b pic x(3) redefine a.
procedure division.
move 'ABC' to a. (as you are redefining, b will contain ABC)
display b.
add 2 to b.
(This 'add' will spawn following:
pack - 'ABC' = x'C1C2C3' will get packed as 123
add 2 to 123 = 125
unpack to display 125 )
display a. 125
display b. |
You WILL get S0C7 when adding in the packed field which is not numeric.
For example, instead of ABC move @#$ to the variable, you will get S0C7. Hope I am clear enough this time. |
|
Back to top |
|
|
sudip_ghanvat
New User
Joined: 05 Apr 2007 Posts: 15 Location: pune
|
|
|
|
Abhijit,
my second field is
01 B pic 9(3) redefine a
not alphnumeric... |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Same S0C7 as the data in the memory is not a numeric data. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Quote: |
my second field is
01 B pic 9(3) redefine a |
Yes i know that. I have copied the code which was pasted by you.
If you declare it numeric then only code will compile and answer is, it will display 125 in this case.
I have explained that there is a large possibility that you may encounter S0C7 in such case ( Adding number to alphanumeric data, which you are doing).
However there will not be S0C7 in 'this case' because 'ABC' will be packed to 123 numeric and will give numeric result. |
|
Back to top |
|
|
sudip_ghanvat
New User
Joined: 05 Apr 2007 Posts: 15 Location: pune
|
|
|
|
Thanks abhijit.
This is the i was excepting..... |
|
Back to top |
|
|
|