2009 Oct 27 12:44 PM
Hi Fellas ...
I need a FM to remove all kind of characters in a char variable. See the example.
DATA: lv_char TYPE char10 VALUE 'ABC123',
lv_num TYPE char 10.
lv_num = lv_char+3(3).
That is one possibility, however, I also can have:
DATA: lv_char TYPE char10 VALUE 'A1B2C3',
lv_num TYPE char 10.
How I can separate the lv_char to have the same 123 in variable lv_num ?
I can have all kind of possibilities of numbers and characters scrambled.
Thx.
Hi Fellas ...
I need a FM to remove all kind of characters in a char variable. See the example.
DATA: lv_char TYPE char10 VALUE 'ABC123',
lv_num TYPE char 10.
lv_num = lv_char+3(3).
That is one possibility, however, I also can have:
DATA: lv_char TYPE char10 VALUE 'A1B2C3',
lv_num TYPE char 10.
How I can separate the lv_char to have the same 123 in variable lv_num ?
I can have all kind of possibilities of numbers and characters scrambled.
Thx.
2009 Oct 27 12:52 PM
Hi,
You wont need a special FM for this. Have a look at this which was discussed earlier today
Vikranth
2009 Oct 27 12:53 PM
Hi,
You could try this small piece of code. I pasted this as a reply for some thread in the morning
DATA : const TYPE string VALUE 'CAD0586/08',
moff TYPE i,
mlen TYPE i,
ans TYPE string,
len TYPE i,
temp TYPE i.
FIND REGEX '([[:alpha:]]*)' IN CONST
IGNORING CASE
MATCH OFFSET MOFF MATCH LENGTH MLEN.
len = strlen( const ).
temp = len - mlen.
ans = const+mlen(temp).
WRITE: ans.
Or if you want only an FM,
go through this link
2009 Oct 27 12:53 PM
2009 Oct 27 12:55 PM
Hi,
use SCP_REPLACE_STRANGE_CHARS or
use FM SF_SPECIALCHAR_DELETE
Import parameters Value
WITH_SPECIALCHAR ASDASD@@#$ASDASD<
Export parameters Value
WITHOUT_SPECIALCHAR ASDASDASDASD
or you can use the below statement.
REPLACE ALL OCCURRENCES OF REGEX '[^[:alnum:]]' IN lv_text WITH ''.or here is another sample code.
first cout the string lenght..
DATA: w_string(255) TYPE c,
w_str(255) type c,
w_c1 TYPE i,
w_c2 TYPE i,
w_count TYPE i,
w_sub_str TYPE c.
CONSTANTS : c_str(22) VALUE '&*=!@#$%[]{}\^|;`"_~'. "Prohibited Character still you ca add SPL characters
w_count = STRLEN( w_str ).
* Clears the string
CLEAR w_string.
w_c2 = 0.
DO w_count TIMES.
w_sub_str = w_str+w_c1(1).
IF w_sub_str CN c_str OR w_sub_str EQ space.
w_string+w_c2(1) = w_sub_str.
w_c2 = w_c2 + 1.
ENDIF.
w_c1 = w_c1 + 1.
ENDDO.
CLEAR: w_c1, w_count.
SHIFT w_string LEFT DELETING LEADING space.Edited by: Harini Gopinath on Oct 27, 2009 6:31 PM
2009 Oct 27 12:56 PM
try this:
PARAMETERS: text type string.
REPLACE ALL OCCURRENCES OF REGEX '([[:alpha:]])' IN text WITH space.
write text.
2009 Oct 27 1:29 PM
Hi Bruno,
<li>Try this way. I have just come to know this method today.
Thanks
Venkat.O
DATA : lv_char TYPE string VALUE 'A1B2C3'.
REPLACE ALL OCCURRENCES OF REGEX '([[:alpha:]])' IN lv_char WITH space.
write lv_char.
2009 Dec 04 12:32 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |