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 find length of a varchar string...

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


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Fri Jul 22, 2005 1:44 am    Post subject: How to find length of a varchar string... Reply with quote

Hi,

Is there any function to find out a length of a varchar string...
Thanks in advance.
Back to top
View user's profile Send private message Send e-mail
Brian
Beginner


Joined: 12 Aug 2003
Posts: 95
Topics: 6

PostPosted: Fri Jul 22, 2005 3:16 am    Post subject: Reply with quote

Paneendra,

Why dont you try writing one of your own. You can look at the INSPECT verb for motivation.

Cheers
Brian
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Fri Jul 22, 2005 3:20 am    Post subject: Reply with quote

Brian,

I need a function like LENGTH(...) to find out the length.
Back to top
View user's profile Send private message Send e-mail
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Fri Jul 22, 2005 4:56 am    Post subject: Reply with quote

Hi,

There is a function to find out the length, but it is not working exactly for all the inputs. So we used the following code to finding the length for varchar. See whether it will be useful for you.

MOVE FUNCTION REVERSE(O-XDONGEN-TEXT-T) TO XDONGEN1
INSPECT XDONGEN1 TALLYING COUNT1 FOR LEADING SPACES
COMPUTE L1 = LENGTH OF XDONGEN1 - COUNT1

here O-XDONGEN-TEXT-T is the varchar. first you reverse it thru reverse function.
using inspect you will get the leading spaces count into xdongen1. finaly the length
will be in l1 by caliculating length of xdongen1 minus count1.
this method worked exactly for all types of inputs.

cheers!!
Nadh
Back to top
View user's profile Send private message Send e-mail
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Sun Jul 24, 2005 9:45 pm    Post subject: Reply with quote

Hi Nadh,

You don't need the move:

INSPECT FUNCTION REVERSE(TEXT1) TALLYING L FOR LEADING SPACES

works and doesn't change the value of TEXT1.
_________________
Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Jul 27, 2005 6:35 am    Post subject: Reply with quote

vkphani,

Please search before posting.

http://www.mvsforums.com/helpboards/viewtopic.php?t=1282&highlight=length

http://www.mvsforums.com/helpboards/viewtopic.php?t=525&highlight=length

http://mvsforums.com/helpboards/viewtopic.php?t=3185&highlight=length

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