2009 Nov 06 4:26 AM
Hi ,
I have a field 'zxxx'.
In the program i have spl characters in between so
so i executed the following code
IF i_zpem-xxxxx CA '~!@#$%^&*()-:;/'.
REPLACE ALL OCCURRENCES OF REGEX '[ [:punct:] ]' IN I_Zpem-xxxx WITH ''.
ENDIF.
Its working fine but there is an extra space coming in at the end for some values
Ex : '23452sdfg '
'236767dfg'
'73452sdf87 '
'2345 2356' " note this is valid,space can be in the middle
so we cannot use condence because space in the middle is accepted so
how can we remove the space at the end.
2009 Nov 06 4:28 AM
Hello,
You can use CONDENSE with NO-GAPS addition. This will supress the space even if it's in the middle of the string
Vikranth
2009 Nov 06 4:28 AM
Hello,
You can use CONDENSE with NO-GAPS addition. This will supress the space even if it's in the middle of the string
Vikranth
2009 Nov 06 4:38 AM
Hi Vikranth ,
We cannot use CONDENCE with NOGAPS because space is accepted in middle for few fields
Ex: '2435 2456 5785' " it is a valid entry
'3455 3454 3423 ' " it is not a valid entry because there is extra space at the end.
2009 Nov 06 4:41 AM
You can try this:
data: var1 type string value '3455 3454 3423 '. " give space using Alt+255
data: len type i.
len = strlen( var1 ).
len = len - 1.
var1 = var1+0(len).
write:/ var1.
2009 Nov 06 4:48 AM
Hi Mahesh
the out put length varies
ex:
'23453434 '
'2435 2456 5785'
'3455 3454 3423 '
'3455 3456 2567'
'3454677453 '
3678 4267 8545 '
the length varries so how can we implement this
2009 Nov 06 4:53 AM
Since it is defined as variable, the above code works for any string length.
2009 Nov 06 5:14 AM
Hi Ravi Kiran,
Don't use NO-GAPS addition with CONDENCE just use only CONDENCE and it will work for you.
DATA: VAR1 TYPE STRING VALUE '3455 3454 3423 '. " Normal Space.. will not work if you do ALT+255
DATA: LEN TYPE I.
CONDENSE VAR1.
WRITE: / VAR1.
@ Mahesh,
Just for my curiosity can you explain me...
What's the difference between normal space and space (ALT + 255) ??
I am wondering why it behaves differently with these two things...
Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
ilesh Nandaniya
2009 Nov 06 5:40 AM
hi ravi ,
Declare like this ,
data : z(10) type c value '1234 56 ' .
data : k(10) type n .
data : m type i .
k = z .
m = i .
write m .
regards
Deepak .
2010 Jan 28 9:09 AM