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 

conversions from Alphanumeric to smallint with left justifie

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


Joined: 25 Jan 2007
Posts: 4
Topics: 1

PostPosted: Tue Feb 13, 2007 11:08 pm    Post subject: conversions from Alphanumeric to smallint with left justifie Reply with quote

hi we get a set of records in the file and they got to updated in the table the value we receive from the file is Alphanumeric but the corresponding values in the table is small int for some cases and numeric in other cases.
now i need to updated the records in the table and they need to left justified how to acheive this???// Please help....
Back to top
View user's profile Send private message
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Tue Feb 13, 2007 11:15 pm    Post subject: Reply with quote

Why can't you simply move this alphanumeric value into the host variable declared for your table column and update the table?
_________________
Regards,
Programmer
Back to top
View user's profile Send private message
AshStar
Beginner


Joined: 25 Jan 2007
Posts: 4
Topics: 1

PostPosted: Wed Feb 14, 2007 12:52 am    Post subject: Reply with quote

No since we got to left justify the values we cant move it directly for instance if the value is spaceXspace or spacespaceX it should be moved as X only.....
Back to top
View user's profile Send private message
hareshh
Beginner


Joined: 13 Dec 2006
Posts: 16
Topics: 0

PostPosted: Wed Feb 14, 2007 1:35 am    Post subject: Reply with quote

Hi AshStar,

How about NUMVAL intrinsic function, please check documentation link

Arrow http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/1.6.6.3?SHELF=&DT=20020923143836

Regards,
Haresh. Mr. Green
Back to top
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Feb 14, 2007 1:45 am    Post subject: Reply with quote

AshStar,

Additional Info.Please check this links:

http://www.mvsforums.com/helpboards/viewtopic.php?t=7518&highlight=numval

http://www.mvsforums.com/helpboards/viewtopic.php?t=6153&highlight=numval
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
hareshh
Beginner


Joined: 13 Dec 2006
Posts: 16
Topics: 0

PostPosted: Wed Feb 14, 2007 1:49 am    Post subject: Reply with quote

Hi AshStar,

I think NUMVAL will make it right justify but you need Left justify so we can do this as shown-

A X(10)
B 9(10)

J = 1

PERFORM VARYING I FROM 1 BY 1 UNTIL I > 10
IF A(I:1) EQUAL SPACES
CONTINUE
ELSE
MOVE(I:1) TO B(J:1)
ADD +1 TO J
END-IF
END-PERFORM

Regards,
Haresh.
Back to top
View user's profile Send private message
hareshh
Beginner


Joined: 13 Dec 2006
Posts: 16
Topics: 0

PostPosted: Wed Feb 14, 2007 1:52 am    Post subject: Reply with quote

Cool Shekar boss is taking you to the right link Very Happy
Back to top
View user's profile Send private message
AshStar
Beginner


Joined: 25 Jan 2007
Posts: 4
Topics: 1

PostPosted: Wed Feb 14, 2007 3:16 am    Post subject: Reply with quote

hi thanks a lot...

Is it possible to acccompolish this using sort?
Back to top
View user's profile Send private message
AshStar
Beginner


Joined: 25 Jan 2007
Posts: 4
Topics: 1

PostPosted: Wed Feb 14, 2007 3:24 am    Post subject: Reply with quote

hi

one more question... if my value is "003" will the NUMVAL function truncate the preceding zeroes and the provide the value is "3"....
Back to top
View user's profile Send private message
hareshh
Beginner


Joined: 13 Dec 2006
Posts: 16
Topics: 0

PostPosted: Wed Feb 14, 2007 4:00 am    Post subject: Reply with quote

Quote:

if my value is "003" will the NUMVAL function truncate the preceding zeroes and the provide the value is "3"


Hi AshStar,

Yes. Please check the document link provided in my previous post there is example of '+001.23' it is simillar to what you are looking for.

Regards,
Haresh. Mr. Green
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Feb 14, 2007 6:56 am    Post subject: Reply with quote

AshStar,

Woah. Just read the whole thread and you are just complicating a simple issue.

Use NUM-VAL function and you are all set , you don't have to worry about removing leading zeros.If your db2 table columns are defined as Decimal or integer they will automatically converted to their respective format.

What do you need sort for ?


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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