08-21-2008 1:09 PM
Hi all,
I need to know , whether there is any command available
to remove the extra spaces in a String.
Thanks in advance,
Uday Kumar.
08-21-2008 1:11 PM
08-21-2008 1:11 PM
08-21-2008 1:11 PM
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) TYPE c 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,
Vijetha.
08-21-2008 1:13 PM
08-21-2008 1:13 PM
hi,
you can use any of the following
CONDENSE field.
SHIFT field LEFT DELETING LEADING space.
SHIFT field RIGHT DELETING TRAILING space.
regards,
Peter
08-21-2008 1:14 PM
08-21-2008 1:24 PM
Hi Uday,
You can use CONDENSE command.The syntax is as below:
CONDENSE <c> [NO-GAPS].
This statement removes any leading blanks from the field <c> and replaces other sequences of blanks by exactly one blank. If the addition NO-GAPS is specified, all blanks are removed.
Regards,
Ashutosh