MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to Convert Numeric Item to COMP

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
vini
Intermediate


Joined: 12 Jan 2004
Posts: 240
Topics: 48
Location: Maryland

PostPosted: Thu Jun 30, 2005 7:33 pm    Post subject: How to Convert Numeric Item to COMP Reply with quote

Hi,

I have following data items

*Input from a File
10 FIPS-CODE PIC 9(5).
*Database host variable Item
10 OSA-FIPS-CD PIC S9(9) COMP.

MOVE FIPS-CODE TO OSA-FIPS-CD

Now, when I use OSA-FIPS-CD in the where clause of a Select Query in Db2 it does not result in any matches because the value after the move changes owing to the different formats of numeric and Comp items.

However, is there a way to do this comparison successfully , am I missing something ?

Thnks.

P.S: I did a search and found some JCL solutions but I have to do this in the program itself.
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 699
Topics: 63
Location: USA

PostPosted: Fri Jul 01, 2005 12:38 am    Post subject: Reply with quote

try compute.
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12369
Topics: 75
Location: San Jose

PostPosted: Fri Jul 01, 2005 5:11 am    Post subject: Reply with quote

vini,

If the input file has embedded spaces(left or right justfied) in the data then the conversion will be wrong.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vini
Intermediate


Joined: 12 Jan 2004
Posts: 240
Topics: 48
Location: Maryland

PostPosted: Fri Jul 01, 2005 8:21 am    Post subject: Reply with quote

There are no spaces in FIPS-CODE. For ex..a value of 39011 when moved to OSA-FIPS-CD results in a completely different value. IT may have to do with the fact that COMP fields have to be moved to a edited item before display ..but the problem here is not just of display ...
Db2 will not allow equating a column defined as INTEGER (PIC S9(9) COMP) with a non COMP item , gives a pre-compiler error.

I am not sure how using COMPUTE to equate the two items will make a difference Confused ,I will be trying that now and posting back if that makes any difference.
Back to top
View user's profile Send private message
NASCAR9
Intermediate


Joined: 08 Oct 2004
Posts: 274
Topics: 52
Location: California

PostPosted: Fri Jul 01, 2005 10:04 am    Post subject: Reply with quote

Vini,
This is a signed field 10 OSA-FIPS-CD PIC S9(9) COMP and you varible is not.
I would think a simple move would work if both a positive. You could also do like Dibakar suggested and compute OSA-FIPS-CD = varible * +1 or maybe -1.
NASCAR9
_________________
Thanks,
NASCAR9
Back to top
View user's profile Send private message
vini
Intermediate


Joined: 12 Jan 2004
Posts: 240
Topics: 48
Location: Maryland

PostPosted: Fri Jul 01, 2005 10:50 am    Post subject: Reply with quote

Using COMPUTE to multiply FIPS-CODE by 1 did the trick Smile Thnks !!!
Back to top
View user's profile Send private message
vini
Intermediate


Joined: 12 Jan 2004
Posts: 240
Topics: 48
Location: Maryland

PostPosted: Fri Jul 01, 2005 11:12 am    Post subject: Reply with quote

Infact simply equating the two variables using compute also works without having to do any multiplication. Whew !!!
Back to top
View user's profile Send private message
vini
Intermediate


Joined: 12 Jan 2004
Posts: 240
Topics: 48
Location: Maryland

PostPosted: Fri Jul 01, 2005 11:17 am    Post subject: Reply with quote

Infact simply equating the two variables using compute also works without having to do any multiplication. Whew !!!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group