Finding the Length of a string

4 posts / 0 new
Last post
Finding the Length of a string





I have to find the length of a string. Lets say the variable is defined as
Now this employee name may have a name as small as "DEEPAK"
so if I find the length of this variable using 
then I would get the length as 20, while I am looking for the 
exact length of item contained in the variable i.e 6 as in this case
"; ; ; ;
Cobol/JCL opporunity
I have a Cobol/JCL Lead developer opening with my client in Charlotte, NC. IF you have any additional experience working with high volume document applications or have these application experience (HP Exstream Dialogue or Streamweaver) then you are a great fit for this position. It is a lead position. Please contact me at the following address: Best regards, Brian Gaudioso Volt Workforce Solutions
Actual length of the string.

Various ways of doing this not sure which would be more efficient, it may depend on the average lenght of the string and the rules around how you want to split it up.

Simplest method:

01 i pic s9(4) comp.

perform varying i from +20 by -1 until Ws-emp-name(i:1) not = space end-perform

or string ws-emp-name delimited by space into ws-work-space pointer ws-emp-name-length end-string

not sure of the exact syntax of the string command please look at the cobol manual. but the ws-emp-name-length will be the string length +1.

Joined: 07/07/2011 - 19:59
Determine the length of the string

use the iuspect statement:

01 ws-emp-name-length pic s9(4) comp.
move 0 to ws-emp-name-length
inspect ws-emp-name tallying ws-emp-name-length before initial ' '

Log in or register to post comments
Sponsored Listing