2008 Mar 28 8:04 AM
Hi Experts,
I have one field with type string. Now you enters some data with star key.
For example :
test*
z*
zsample_*
Now my requirement is I need the characters only( test, z, zsample). I dont want symbols like *, _.
So how can i eliminate these symbols from my field. Its very urgent.
Anyone help me on this issue.
Points will be rewarded for all suggestions.
2008 Mar 28 8:08 AM
data : v_string(10) value 'ztest*'.
translate v_string using '* '.
condense v_string no-gaps.
write v_string.
data : v_string(10) value 'ztest*'.
translate v_string using '* '.
condense v_string no-gaps.
write v_string.
2008 Mar 28 8:08 AM
data : v_string(10) value 'ztest*'.
translate v_string using '* '.
condense v_string no-gaps.
write v_string.
2008 Mar 28 8:09 AM
Check the code.
REPORT ztest_m1 .
parameters: p_text(50) type C.
data: w_len type i,
W_OFF TYPE I.
w_len = strlen( p_text ).
do w_len times.
W_OFF = SY-INDEX - 1.
if sy-abcde cs p_text+W_OFF(1).
else.
p_text+W_OFF(1) = SPACE.
ENDIF.
ENDDO.
CONDENSE p_TEXT.
WRITE : p_TEXT.
2008 Mar 28 8:09 AM
Hi
Finding String Length and Avoiding Last Character in the string by using offset is the only easy way.
If you know the exact length of the variable value, then you can do offset directly. So that u can remove all the unwanted characters
reward if useful
Regards
Ravi
2008 Mar 28 8:10 AM
Use shift command to shift the contents to right until the last character is wanted one, then shift left to delete tle leading blanks.
pseduo code:
do until right most character is a valid one.
shift var right by 1 PLACES.
enddo.
shift var left deleteing leading spaces.
2008 Mar 28 8:12 AM
Hi
parameters: p_text(50) type C,
p_word(50) type C.
data: w_len type i,
W_OFF TYPE I.
w_len = strlen( p_text ).
wa_len = w_len - 1.
p_word = p_text+0(w_len).
CONDENSE p_word.
wRITE : p_word.
2008 Mar 28 8:15 AM
Hi,
use the following code
DATA: str type string.
DATA: w_len type I.
w_len = STRLEN( str ).
w_len = w_len - 1.
str = str+0(w_len).
regards
Mahesh
2008 Mar 28 8:12 AM
this will solve ur problem..
data: count type n.
value = 'TESTZ'.
count = strlen( value ).
count = count - 1." count = 4
value = value+0(count). "value = TEST.
write value.
Regards
Sugumar G
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |