Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Adding numeric data to comp-3

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Adding numeric data to comp-3
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: 686
Location: Earth

PostPosted: Wed May 23, 2007 6:16 pm    Post subject:
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    Post subject:
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: 686
Location: Earth

PostPosted: Wed May 23, 2007 6:54 pm    Post subject: Re: Adding numeric data to comp-3
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    Post subject:
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

Site Director


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

PostPosted: Wed May 23, 2007 7:39 pm    Post subject:
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    Post subject:
Reply with quote

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

Site Director


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

PostPosted: Thu May 24, 2007 7:06 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts copying data without knowing location arunsoods DFSORT/ICETOOL 6 Thu Jul 20, 2017 1:03 pm
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us