04-29-2009 3:15 AM
Hi All,
DATA: str1(999),
a(10),
b(10).
DATA: len TYPE i.
a = 'Welcome'.
b = 'To all'.
CONCATENATE a b INTO str1 RESPECTING BLANKS.
len = STRLEN( str1 ).
WRITE: len.
result : 16.
If I declared str1 as string result is 20. Because in above case empty space is truncated at last .
So any otherway to getting result 20 with out declaring str1 as string.
04-29-2009 3:23 AM
before concatenating fill the blanks space of a and b with some character say _ and concatenate and find the string length.
after concatenating replace all occurance of '_ ' in string1 with ' '.
04-29-2009 3:27 AM
Dear Vinoth
Try as follows
DATA: BEGIN OF sentence,
word1(30) TYPE c VALUE 'She',
word2(30) TYPE c VALUE 'feeds',
word3(30) TYPE c VALUE 'you',
word4(30) TYPE c VALUE 'tea',
word5(30) TYPE c VALUE 'and',
word6(30) TYPE c VALUE 'oranges',
END OF sentence,
text TYPE string.
text = sentence.
04-29-2009 3:54 AM
dear Nelson,
you are telling with string , but i need it with out string , using only character format str(999) .
04-29-2009 4:50 AM
what is the problem using string instead.
Regards,
Lalit Mohan Gupta.
04-29-2009 6:15 AM
Try this out.
DATA: str1(999),
a(10),
b(10).
DATA: len TYPE i,
wc(2) value ' #'.
a = 'Welcome'.
b = 'To all'.
translate a using wc.
translate b using wc.
concatenate a b into str1.
len = strlen( str1 ) .
replace all occurrences of '#' in str1 with space .
write : len.
Result : 20.
This will solve the issue
Regards,
Gurpreet
04-29-2009 6:48 AM
Hi vinoth ,
To get spaces at last ,
data : str1 type char10 ,
len type i .
str1 = 'the ' . " space given by pressing space bar button
len = STRLEN( str1 ). " in len we get it as 3 , coz 'the ' is 3 only .
**************
str1 = 'the ' . " space given by pressing ALT 2 5 5
len = STRLEN( str1 ). " in len we get it as 4 , coz 'the ' is 3 and 1 space is given by pressing ALT 255 .
This works,
Hope it might be helpfull,
Regards,
Aby
10-14-2011 9:09 AM