Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Calculate the length of a string

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sunish

New User


Joined: 23 May 2005
Posts: 19

PostPosted: Fri Jun 09, 2006 9:55 am    Post subject: Calculate the length of a string
Reply with quote

Hi

i want to calculate the length of a string.The varilable is declared

01 GR.
05 A PIC X(200).
05 B PIC S9(3) COMP.

now the varilable "A" contains "god is great ". the actual length of the srting is 12. Please tell me how to calculate the lenght.

thank you
Back to top
View user's profile Send private message

Aji

New User


Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

PostPosted: Fri Jun 09, 2006 10:48 am    Post subject: Re: calculate length
Reply with quote

Hi


Please try out the code below.
INSPECT FUNCTION REVERSE(TEXT1) TALLYING
L FOR LEADING SPACE

compute l = length of text1 - l


Regards

Aji Cherian
Back to top
View user's profile Send private message
gowtham_1982
Warnings : 1

Active User


Joined: 02 Dec 2005
Posts: 109

PostPosted: Mon Jun 12, 2006 8:32 am    Post subject: Re: calculate length
Reply with quote

sunish wrote:
Hi

i want to calculate the length of a string.The varilable is declared

01 GR.
05 A PIC X(200).
05 B PIC S9(3) COMP.

now the varilable "A" contains "god is great ". the actual length of the srting is 12. Please tell me how to calculate the lenght.

thank you


Hi sunish,

please try this code...

compute b = function length of (a).

suggestions welcomed...

gowtham
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Mon Jun 12, 2006 10:38 am    Post subject:
Reply with quote

hi gowtham_1982,

AJI is right.

You can't go for FUNCTION Lenght of (a) directly.
SInce the lenght includes the following spaces which is not the requirement.

~Vamsi
Back to top
View user's profile Send private message
sundaresanjs

New User


Joined: 29 May 2006
Posts: 18
Location: USA

PostPosted: Sat Jun 17, 2006 1:07 pm    Post subject:
Reply with quote

sunish,

i have done a program regarding it, i think it may be helpful for u,
(using display(name(2:1)) which gives the value of the second position in name)

01 GR.
05 A PIC X(200).
05 B PIC S9(3) COMP

according to ur program a has value god is great,

MOVE 300 TO I.
PERFORM 300 TIMES
IF A(I:1) = " " THEN NEXT SENTENCE
ELSE
COMPUTE LEN = 300 - I
GO TO PRINTPARA
END-IF
END-PERFORM.
PRINTPARA.
DISPLAY "THE LENGTH OF STRING IN A IS : ", LEN.
STOP RUN.

comment if any errors

regards,
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Wanted to calculate TRK when i have B... Balu5491 JCL & VSAM 7 Wed Jul 19, 2017 5:43 pm
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Length of Tape file Mohan Kothakota JCL & VSAM 9 Thu Apr 20, 2017 10:24 pm
No new posts Sort Large record length cmsmoon DFSORT/ICETOOL 14 Tue Apr 11, 2017 5:49 pm
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us