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 

Finding the length of the String

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


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Tue Nov 02, 2004 1:23 am    Post subject: Finding the length of the String Reply with quote

Hi,

I have a record declared as below

01 rec pic x(100).

I will be getting variable length string into that record. I want to move that data to db2 table field which is of varchar. so I have to find out the length of the string in record.

for eg. A community of and for mvs professionals.

using length function in cobol i'm getting the bytes used by the rec. But my requirement is to find the length of the string. Can any one suggest me how to do it. I have one solution with me that is searching in the record for non space character in the record starting from back. But as this program is to be run in batch it is not effiecient way i believe. Pls. suggest any other way to find the length of the string. in COBOL

Thanks in advance!!!


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


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

PostPosted: Tue Nov 02, 2004 4:52 am    Post subject: Reply with quote

Nadh,

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

Apart from the solutions listed in the above links you can also use

Code:

SELECT LENGTH('A COMMUNITY OF AND FOR MVS PROFESSIONALS')   
  FROM SYSIBM.SYSDUMMY1;                                     


Hope this helps...

Cheers

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


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Fri Nov 05, 2004 11:31 am    Post subject: Reply with quote

Hi Kolusu,

Thanks for your links.
by the way i want to find the lenth of the string in a record in cobol not in db2.
it will be great if you suggest a method for it.

nadh
Back to top
View user's profile Send private message Send e-mail
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Nov 05, 2004 11:47 am    Post subject: Reply with quote

nadh,

I think you mis-understood what Kolusu said. He gave u a DB2 Plugin solution. ie. you can use Db2 features inside your cobol program to achieve what you need.

Code:

SELECT LENGTH('A COMMUNITY OF AND FOR MVS PROFESSIONALS')   
  FROM SYSIBM.SYSDUMMY1; 


Instead of the Hard coded value 'A COMMUNITY......' pass your variable/group variable (which contains the record you read from your input file) as a parameter to the above mentioned SQL statement to get the desired results.

Code:

EXEC SQL
   SELECT
        LENGTH(:WS-INPUT-RECORD)
  INTO
        :WS-LENGTH
  FROM
        SYSIBM.SYSDUMMY1
END-EXEC


Hope this helps,

Phantom
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: Fri Nov 05, 2004 12:09 pm    Post subject: Reply with quote

Quote:

by the way i want to find the lenth of the string in a record in cobol not in db2.


Nadh,

The 2 links in my first post discusses a COBOL solution. I also supplied an additional solution of using DB2 in a cobol program.

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


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Sat Nov 06, 2004 3:55 am    Post subject: Reply with quote

Thank you Kolusu, the links provided by you solved my problem. Thank you very much.


nadh
Back to top
View user's profile Send private message Send e-mail
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