‎2009 Aug 13 8:29 PM
I have to remove any non-alpha numerics from something like:
SPMA-09-AF-M002-A7
The result would be:
SPMA09AFM002A7
Is there a function module that would do this?
Edited by: Rob Burbank on Aug 13, 2009 3:44 PM
‎2009 Aug 13 8:35 PM
Hi,
Try SCP_REPLACE_STRANGE_CHARS or
use
REPLACE ALL OCCURRENCES OF REGEX '[^[:alnum:]]' IN text WITH ''.
Regards,
Vik
‎2009 Aug 13 8:35 PM
Hi,
Try SCP_REPLACE_STRANGE_CHARS or
use
REPLACE ALL OCCURRENCES OF REGEX '[^[:alnum:]]' IN text WITH ''.
Regards,
Vik
‎2009 Aug 13 8:37 PM
Hi,
if you know every possible non-alpha chars, you could use translate:
TRANSLATE gc_alpha USING '- '.
CONDENSE gc_alpha NO-GAPS.
Regards,
Frisoni
‎2009 Aug 13 8:41 PM
Hi,
If it is only one special character You can try like below:
data: lv_hash value '-'.
replace all occurences of lv_hash by space into variable.
Regards,
Himanshu
‎2009 Aug 13 9:01 PM
Hi,
Use Replace or Split stmt to do it.
data : a(25) type c VALUE 'SPMA-09-AF-M002-A7',
a1 type c value '-'.
replace ALL OCCURRENCES OF a1 in a WITH space.
write: a.data : begin of itab OCCURS 0,
text(50) type c,
end of itab.
data : a(25) type c VALUE 'SPMA-09-AF-M002-A7',
a1 type c value '-'.
data b(50) type c.
SPLIT a at a1 INTO TABLE itab.
loop at itab.
CONCATENATE itab-text
b
INTO b.
endloop.
write b.Thanks & regards,
ShreeMohan
‎2009 Aug 13 9:39 PM
I don't think there is any function module for that but you can write simple code as follows.
PARAMETERS: p_string(20) TYPE c.
DATA: v_length TYPE i,
v_offset TYPE i.
START-OF-SELECTION.
WRITE:/ p_string.
v_length = STRLEN( p_string ).
CHECK v_length > 0.
DO v_length TIMES.
v_offset = sy-index - 1.
IF p_string+v_offset(1) CA '0123456789' OR
p_string+v_offset(1) CA sy-abcde.
ELSE.
CLEAR p_string+v_offset(1).
ENDIF.
ENDDO.
CONDENSE p_string NO-GAPS.
WRITE:/ p_string.