View previous topic :: View next topic
|
Author |
Message |
Annie P
New User
Joined: 26 Jun 2006 Posts: 7
|
|
|
|
Can I add a redefined variable to another variable?
eg:
01 B PIC X(5).
01 A redefines B 9(5).
....
Add A to C.
Now when i display C i get junk values.
C was already initialized.
thanks in advance. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Yes, you can add a redefined variable to another variable.
"junk values" is descriptive but not very informative. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Junk values will be there if you dont initialize that variable. (A,C in this case)
What what does 'C' contain?
Initialize both variables with desired values then you will get correct results. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Your posted code is incomplete and/or invalid. You need to post what value you put in A/B as well as the value in C. Before and ADD is issued, there must be valid numbers in the operands.
From what you posted, i'm surprised that a s0c7 did not occur.
If these (A/B,C) are user entered values, they must be checked to ensure they contain valid numeric values. If this is not done, the job will eventually abend in production. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
No S0C7 becuase the data are not packed decimal.
It is possible for the code generated from DISPLAY arithmetic to convert to packed decimal and then back, which could elicit a S0C7, but I think this is only with signed fields. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Phrzby Phil wrote: |
No S0C7 becuase the data are not packed decimal.
It is possible for the code generated from DISPLAY arithmetic to convert to packed decimal and then back, which could elicit a S0C7, but I think this is only with signed fields. |
Not quite, the mainframe can add primarily two ways, either packed or binary.
The zoned digits are packed to work areas, added and unpacked back. While the pack/unpack are immune to exception, the add packed is not.
To add binary, the zoned digits are packed, converted to binary, added, converted to decimal and unpacked. While the pack/unpack are immune to exception (as are the binary add and the convert to decimal), the convert to binary is not.
Not all garbage results in a S0C7, but there's a good chance that one can happen from random junk. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Thanks for the correction. |
|
Back to top |
|
|
|