07-10-2007 8:16 AM
Hi all,
Iam taking a txt field txt50 which is containing many unwanted spaces between words in it. and i want to remove all unwanted spaces between words. Please tell me the solution it.
07-10-2007 8:17 AM
07-10-2007 8:17 AM
07-10-2007 8:24 AM
07-10-2007 8:30 AM
Hi,
than try without no-gaps like this:
data: txt type string.
*
txt = 'txt with space'.
write: / txt.
*
CONDENSE txt.
*
write: / txt.
07-10-2007 8:18 AM
07-10-2007 8:19 AM
Hi,
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.
<b>Reward points</b>
Regards
07-10-2007 8:20 AM
Use Replace ' ' in text50 to ''. " Check syntax
or try condense text50.
reward points if helpful
07-10-2007 8:23 AM
Hi,
try this:
data: txt type string.
*
txt = 't x t w i t h s p a c e'.
write: / txt.
*
CONDENSE txt no-gaps.
*
write: / txt.
Regards, Dieter
07-10-2007 10:16 AM
07-10-2007 10:48 AM
Hi,
The CONDENSE statement deletes redundant spaces from a string:
CONDENSE <c> [NO-GAPS].
This statement removes any leading blanks in the field <c> and replaces other sequences of
blanks by exactly one blank. The result is a left-justified sequence of words, each separated by
one blank. If the addition NO-GAPS is specified, all blanks are removed.
DATA: STRING(25) VALUE ' one two three four',
LEN TYPE I.
LEN = STRLEN( STRING ).
WRITE: STRING, '!'.
WRITE: / 'Length: ', LEN.
CONDENSE STRING.
LEN = STRLEN( STRING ).
WRITE: STRING, '!'.
WRITE: / 'Length: ', LEN.
CONDENSE STRING NO-GAPS.
LEN = STRLEN( STRING ).
WRITE: STRING, '!'.
WRITE: / 'Length: ', LEN.
Output:
one two three four !
Length: 25
one two three four !
Length: 18
onetwothreefour !
Length: 15
Note that the total length of the field STRING remains unchanged, but that the
deleted blanks appear again on the right.
Regards,
Bhaskar
07-10-2007 10:55 AM