‎2007 Apr 02 1:46 PM
hi could anyone please advice me...how to remove special characters from a string...
thanks in advance..
‎2007 Apr 02 1:49 PM
hi
chk the sample prog:
REPORT zstring.
DATA : ipstr TYPE string.
DATA : opstr TYPE string.
DATA : len TYPE i VALUE 0.
DATA : ch TYPE char1.
DATA : num TYPE i VALUE 0. "No of Characters to be taken
DATA : pos TYPE char3. "Position of Char in the Input String
*Input string
ipstr = '<FT><H><T> Line Clearance </></></>'.
*Removing only "</>"
REPLACE ALL OCCURRENCES OF '</>' IN ipstr WITH ' '.
*Removing only "<"
REPLACE ALL OCCURRENCES OF '<' IN ipstr WITH ' '.
CONDENSE ipstr.
*Length of Input String
len = STRLEN( ipstr ).
DO len TIMES.
*Char by Char
ch = ipstr+pos(1).
pos = pos + 1.
*Scan each char in input String for ">"
FIND '>' IN ch IGNORING CASE.
IF sy-subrc = 0.
num = len - pos.
*Output String
opstr = ipstr+pos(num).
ENDIF.
ENDDO.
WRITE 😕 opstr.
**reward if helpful
regards,
madhu
‎2007 Apr 02 1:50 PM
Hi,
<b>CP</b>
Covers Pattern: True, if the content of operand1 fits the pattern in operand2. Wildcard characters can be used for forming the operand2 pattern, where "" represents any character string, and "+" represents any character. Upper/lower case is not taken into account. If the comparison is true, sy-fdpos contains the offset of operand2 in operand1, whereby leading wildcard characters "" in operand2 are ignored if operand2 also contains other characters. If the comparison is false, sy-fdpos contains the length of operand1. You can select characters in operand2 for a direct comparison by adding the escape symbol "#" before the required characters. For these characters, upper/lower case is taken into account, wildcard characters and the escape symbol itself do not receive special treatment, and trailing blanks in operands of type c are not cut off.
DATA: str1 TYPE string,
str2 TYPE string.
str1 = 'ABCDEFGH'.
str2 = 'CF+H'.
IF str1 CP str2.
Use <b>Translate</b> keyword to remove the special characters by using space.
and after that use <b>Condense</b> .
Cheers,
Simha.
Reward all the helpful answers..
ENDIF.
‎2007 Apr 02 1:51 PM
‎2007 Apr 02 1:57 PM
hI..
data: w_text(50) type C value 'Ram?mohan?45jAGAN'.
data: w_len type i,
W_OFF TYPE I.
w_len = strlen( w_text ).
do w_len times.
W_OFF = SY-INDEX - 1.
if sy-abcde cs w_text+W_OFF(1).
else.
w_text+W_OFF(1) = SPACE.
ENDIF.
ENDDO.
CONDENSE W_TEXT.
WRITE : W_TEXT.