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

COBOL Numeric data issue


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

New User


Joined: 20 Sep 2006
Posts: 6

PostPosted: Tue Aug 28, 2007 6:16 pm
Reply with quote

Hi All,
I am encountering a peculiar problem in one of our COBOL applications. THere is a COBOL program which has (example only) the following
picture clause.

01 WS-VAR1 PIC S9(15)V999 COMP-3.
01 WS-VAR2 PIC S9(15)V999 COMP-3.

These 2 variables are getting their input field from an Oracle Table
field which is of type NUMBER .
Both these variables are getting their input from similar fields which
has following attributes
Length of field is 21, before decimal 18 places, after decimal it has 3 places. ie. (18,3).

DUe to Cobol limitations WS-VAR1 , WS-VAR2 has been described with the above mentioned picture clauses.
Surprisingly WS VAR1 gets its values correctly whereas WS-VAR2 doesnt.
For eg.

If Source field in oracle is 3000058.678 for WS-VAR1, the WS-VAR1 shows
as 1000058.2348 ,but
If Source field in oracle is 3000058.678 for WS-VAR2, the WS-VAR2 shows
as 1000023.4.
Tried everything but didnt work. Would appreciate some thoughts from you.
Thanks
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 28, 2007 6:42 pm
Reply with quote

have you read your post? nothing in your last part of the post makes any sense.

try posting your example input and output again.

There are compiler options which will allow you to go exceed the default 18 digit cobol decimal limitation. But, I don't think that is your problem.
Back to top
View user's profile Send private message
ibmcoolz

New User


Joined: 20 Sep 2006
Posts: 6

PostPosted: Tue Aug 28, 2007 8:38 pm
Reply with quote

Sorry abt the type errors :
The text should read as :

For eg.

If Source field in oracle is 3000058.678 for WS-VAR1, the WS-VAR1 shows
as 3000058.678 ,but
If Source field in oracle is 1000023.478 for WS-VAR2, the WS-VAR2 shows
as 1000023.4.
Tried everything but didnt work. Would appreciate some thoughts from you.
Thanks

Back to top
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: Tue Aug 28, 2007 9:06 pm
Reply with quote

Hello,

Please post the Oracle column definitions and the code where the WS-VAR fields are the receiving fields.

Quote:
01 WS-VAR1 PIC S9(15)V999 COMP-3.
01 WS-VAR2 PIC S9(15)V999 COMP-3.
Were these put in by copy/paste or were they typed into the post? If wa-var2 was defined with only 1 decimal place and there was no rounding, 1000023.4 is the correct result.
Back to top
View user's profile Send private message
ibmcoolz

New User


Joined: 20 Sep 2006
Posts: 6

PostPosted: Wed Aug 29, 2007 4:43 pm
Reply with quote

THe fields WS-VAR1 , WS-VAR2 are target/destination fields.
The source fields are both of type NUMBER in Oracle . THe field format is :
Length of field is 21.Before decimal 18 places, after decimal it has 3 places. ie. (18,3).
Hope this clarifies.
The problem as mentioned earlier is one of the fields ie. WS-VAR1 is
getting correctly populated whereas WS-VAR2 is not getting correctly populated.

Thanks,
Arvind
Back to top
View user's profile Send private message
sanjayis01
Warnings : 1

New User


Joined: 13 Jun 2007
Posts: 55
Location: banaglore

PostPosted: Wed Aug 29, 2007 5:04 pm
Reply with quote

please post your query in clear format

as per my understanding , if ur fetching columns from tables , u should move the values to some working storage variables to get correct values

for example : X is the column name is table and ur moving column X to Y PIC S9(15)V999 COMP-3. variable , later u have to move Y value to Z variable defined as Z pic s9(15)v999 sign leading seperate.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 29, 2007 5:13 pm
Reply with quote

I assume you are using WS-VAR1 & WS-VAR2 as host variables in an SQL statement involving and Oracle DB.
If WS-VAR1 & WS-VAR2 are defined in the COBOL program as you say (i.e. PIC S9(15)V9(3) COMP-3), then
  1. the SQL (which we have not seen) is causing the rounding
  2. the Oracle DB definition of the 2nd column is not what you think.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 29, 2007 5:15 pm
Reply with quote

What is the DCLGEN definition of the two DB columns? Or is it not in your COBOL program?
Back to top
View user's profile Send private message
ibmcoolz

New User


Joined: 20 Sep 2006
Posts: 6

PostPosted: Fri Aug 31, 2007 11:29 am
Reply with quote

Hi,

The problem for the numeric data has since been resolved. THe
problem was traced to the calls to the ORacle database from the COBOL
programs. These are third-party provided softwares, there was an error
in the parameters being passed to the COBOL program. Strangely in the
first case( ie. in case of WS-VAR1) the parameter was being correctly passed and in the second case (ie. for WS-VAR2 ) it was not . This was
traced to one of the LINKAGE section variables getting incorrecly
populated in the calls to the database. We are still trying to decipher
why such a difference would occur.
Thanks to all who spent their valuable time in responding to this query.

Arvind
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: Fri Aug 31, 2007 9:46 pm
Reply with quote

Thank you for posting what you found icon_smile.gif

d
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 How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
Search our Forums:

Back to Top