‎2007 May 25 8:54 AM
Dear Gurus,
I have a string .
'My name is Roshan Lilaram Wadhwani'
I need to find the number of spaces used in this string.
Rather i need to segregate the string in two parts after a particular number of spaces.
Regards,
Roshan Lilaram.
‎2007 May 25 9:12 AM
TRY THIS
DATA : TEXT(50) VALUE 'My name is Roshan Lilaram Wadhwani',
LEN TYPE I,
POS TYPE I,
COUNTER TYPE I,
V_CH,
V_SPACE VALUE ' ',
V_TXT(30),
V_TXT2(20).
COMPUTE LEN = STRLEN( TEXT ).
DO LEN TIMES.
V_CH = TEXT+POS(1).
IF V_CH EQ SPACE.
COUNTER = COUNTER + 1.
ENDIF.
IF COUNTER LT 3.
CONCATENATE V_TXT V_CH INTO V_TXT.
ELSE.
CONCATENATE V_TXT2 V_CH INTO V_TXT2.
ENDIF.
POS = POS + 1.
ENDDO.
WRITE : / V_TXT.
WRITE : / V_TXT2.
REGARDS
SHIBA DUTTA
‎2007 May 25 9:01 AM
Hi,
try the folowing codes:
data :
varxx type string value 'Test',
len type i.
len = strlen( varxx ).
write: varxx, ' Lenght:', len.
len2 = len/2.
segregate the string in two parts like this:
move varxx(len2 ) to temp1.
move varxx+len2 to temp2.
‎2007 May 25 9:02 AM
‎2007 May 25 9:09 AM
hi
You can use the function module SWA_STRINGLENGTH_GET to find the number of spaces in the string.
for this you can call this function module twice.
first when you are not going to set the parameter CONDENSE_NO_GAPS.
and get the length of the string with spaces.
after that call the function module againg and set CONDENSE_NO_GAPS = X.
now the length of the string will be without spaces.
you can substract the two to get the number of spaces.
Reward if helpful.
Mohit
‎2007 May 25 9:12 AM
TRY THIS
DATA : TEXT(50) VALUE 'My name is Roshan Lilaram Wadhwani',
LEN TYPE I,
POS TYPE I,
COUNTER TYPE I,
V_CH,
V_SPACE VALUE ' ',
V_TXT(30),
V_TXT2(20).
COMPUTE LEN = STRLEN( TEXT ).
DO LEN TIMES.
V_CH = TEXT+POS(1).
IF V_CH EQ SPACE.
COUNTER = COUNTER + 1.
ENDIF.
IF COUNTER LT 3.
CONCATENATE V_TXT V_CH INTO V_TXT.
ELSE.
CONCATENATE V_TXT2 V_CH INTO V_TXT2.
ENDIF.
POS = POS + 1.
ENDDO.
WRITE : / V_TXT.
WRITE : / V_TXT2.
REGARDS
SHIBA DUTTA
‎2007 May 28 8:36 AM