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

Adding numeric data to comp-3


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
nanda31

New User


Joined: 30 Mar 2007
Posts: 8
Location: hyderabad

PostPosted: Wed May 23, 2007 5:49 pm
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed May 23, 2007 6:16 pm
Reply with quote

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
View user's profile Send private message
nanda31

New User


Joined: 30 Mar 2007
Posts: 8
Location: hyderabad

PostPosted: Wed May 23, 2007 6:44 pm
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed May 23, 2007 6:54 pm
Reply with quote

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. icon_smile.gif
Back to top
View user's profile Send private message
nanda31

New User


Joined: 30 Mar 2007
Posts: 8
Location: hyderabad

PostPosted: Wed May 23, 2007 7:31 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed May 23, 2007 7:39 pm
Reply with quote

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
View user's profile Send private message
nanda31

New User


Joined: 30 Mar 2007
Posts: 8
Location: hyderabad

PostPosted: Thu May 24, 2007 12:17 pm
Reply with quote

Thanks... it worked. icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu May 24, 2007 7:06 pm
Reply with quote

You're welcome icon_smile.gif
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 Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Adding QMF and SPUFI to the ISPF menu DB2 20
No new posts Check data with Exception Table DB2 0
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top