‎2007 Apr 03 7:45 PM
Hi,
I would like to see a trim function that trims trailing spaces from both sides of the string (not whithin).
Thanks,
AG
‎2007 Apr 03 7:53 PM
You can use the SHIFT. In this example, the trailing spaces are simply not there when using a STRING field.
data: str type string.
data: len type i.
str = ' THIS IS A STRING '.
len = strlen( str ).
write:/ str, len.
shift str left deleting leading space.
len = strlen( str ).
write:/ str, len.
Regards,
RIch Heilman
‎2007 Apr 03 7:51 PM
‎2007 Apr 03 7:53 PM
You can use the SHIFT. In this example, the trailing spaces are simply not there when using a STRING field.
data: str type string.
data: len type i.
str = ' THIS IS A STRING '.
len = strlen( str ).
write:/ str, len.
shift str left deleting leading space.
len = strlen( str ).
write:/ str, len.
Regards,
RIch Heilman
‎2007 Apr 03 7:53 PM
Hi,
Please use CONDENSE statement.
CONDENSE WA_STRING.
Regards,
Ferry Lianto
Thanks, Rich!
Message was edited by:
Ferry Lianto
‎2007 Apr 03 7:56 PM
Of course, CONDENSE would work here too, but don't use NO-GAPS as this will get rid of any spaces within the value.
data: str type string.
data: len type i.
str = ' THIS IS A STRING '.
len = strlen( str ).
write:/ str, len.
condense str.
*shift str left deleting leading space.
len = strlen( str ).
write:/ str, len.
Regards,
Rich HEilman
‎2007 Apr 03 8:02 PM
Hi AG,
There is not function module avialable for TRIM function but your requirement can be achieved with SHIFT statement.
Check this code.
DATA V_STRING TYPE STRING VALUE
' empty string a b c d e f ghijkl'.
<b>SHIFT V_STRING LEFT DELETING LEADING SPACE.</b>
WRITE:/ V_STRING.
<b>CONDENSE</b> will supress spaces(if you had more than one or so) in between words in a string and will a single space between words.
Thanks,
Vinay
‎2007 Apr 04 3:27 PM