View previous topic :: View next topic
|
Author |
Message |
nanda31
New User
Joined: 30 Mar 2007 Posts: 8 Location: hyderabad
|
|
|
|
My requirement is to add a numeric value from file to a comp-3 value from table
Say var1 and var2
where
var1 is coming from a file where I have defined it as
VAR1 PIC 9(04)V99.
and
var2 is coming from a table and defined as
VAR2 PIC S9(9)V9(2) USAGE COMP-3.
file is containing values for var1 as 0100.65. When I am reading the file in var1 and displaying it, var1 is showing 0100.6
So while computing I am getting soc7 abend
Now if I add 100.65 in var1 in the program itself like
MOVE 100.65 TO var1
and then compute var2 = var1 + var2
its working fine.
let me know how can I pass file value correctly into var1 and do the calculation. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
If you have declared variable 9(04)V99 and you are getting output 100.65 then it is time to think..
I say, if it contains 100.65 then output will be printed as 010065.
You told, you are getting S0C7, that is because your data is '0100.6'. Note that there are non numeric charactars('.') in the source data. |
|
Back to top |
|
|
nanda31
New User
Joined: 30 Mar 2007 Posts: 8 Location: hyderabad
|
|
|
|
yeah i understand that. But as per my understanding data from file is not getting passed into the variable var1 correctly. because when I pass 100.65 directly using MOVE statement then there is no problem. Var1 is showing 010065 only.
Is this because some problem in moving the data from file to var1? |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Quote: |
Is this because some problem in moving the data from file to var1? |
I won't call it a problem in MOVE, problem is with the data.
If file has 0100.65 then declare a temp-var as 9(04).99, read file variable in temp-var.
then move temp-var to var1 (var1 9(04)v99) then it should work. |
|
Back to top |
|
|
nanda31
New User
Joined: 30 Mar 2007 Posts: 8 Location: hyderabad
|
|
|
|
even this is giving the same error because (.) of 100.65 is getting stored as a character in 9(4)v99.
if we print this value comes to be 100.6.
V doesnt store any value but . is used for representation. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
The concept of an implied decimal (i.e. 9(5)v99) is that the system knows how to handle arithmetic scaling and alignment for calculatoins. A field with an implied decimal should not contain an actual decimal-point ".".
If you redefine the field as my-dollars (pic 9(4)), a one byte filler, and my-cents (pic v99), you can easily compute the needed value (var2) by using my-dollars + my-cents +whatever other field(s) you want (i.e. var2). |
|
Back to top |
|
|
nanda31
New User
Joined: 30 Mar 2007 Posts: 8 Location: hyderabad
|
|
|
|
Thanks... it worked. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome |
|
Back to top |
|
|
|