Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 

Determining the length of characters before space

Former Member
0 Kudos

How can I use the search functionality to determine the length of the first word before the space?

For example lets suppose the string is 'Uzbekistan Russia USA' how can I use the search or any other functionality to determine the length of Uzbekistan? I cannot use a constant number and I have to dynamically calculate for each string.

With best regards,



Former Member
0 Kudos

data : text(40) value 'Uzbekistan Russia USA' ,



len type i.

split text at space into text1 text2.

compute len = strlen( text1 ).

write : / len.


shiba dutta

0 Kudos

since the number od words are not defined hence u need to split data and take it into a internal table.

data: itab type table of string.

split text at space into itab.

loop at itab.

compute len = strlen( itab ).

write : / len.


Former Member
0 Kudos


DATA: str1 TYPE string,

str2 TYPE string,

str3 TYPE string,

itab TYPE TABLE OF string,

text TYPE string.

text = `What a drag it is getting old`.

SPLIT text AT space INTO: str1 str2 str3,

TABLE itab.

describe str1 length len.

Reward if useful!

Former Member
0 Kudos

Hi Ketan,

try this:

data : text(40) value 'Uzbekistan Russia USA'.

data: begin of itab occurs 0,


end of itab.


data: strlen type i.

split text at space into table itab.


loop at itab.

strlen = strlen( itab-txt ).

write: / itab-txt, strlen.


Regards, Dieter