‎2004 Sep 02 9:57 AM
Hello,
I have the following code.
DATA: tmp TYPE STRING,
result TYPE i.
tmp = 'Craig (Cmehil)'.
IF tmp CS '('.
result = 1.
ENDIF.
write: / result.
IF tmp NS '('.
result = 0.
ENDIF.
write: / result.
However the result should be 1 and then 0 but I get 1 and then 1 again.
How can I find the ( inside of a string?
‎2004 Sep 03 7:18 AM
Hello Craig,
Use following statement. It works allways.
if ls_text CP '('.
do soething.
endif.
BR
Michael
‎2004 Sep 02 10:04 AM
DATA: tmp TYPE STRING.
tmp = 'Craig (Cmehil)'.
write: / tmp.
IF tmp CA '#('.
tmp = 'Found'.
ELSE.
tmp = 'Not Found'.
ENDIF.
write: / tmp.
Sometimes sitting back and thinking and you get that whole apple on the head realization
‎2004 Sep 02 10:21 AM
Hi,
you can use SEARCH f FOR g to find string g in string f.
Regards,
Malgorzata
Message was edited by: Malgorzata Jaworek
‎2004 Sep 02 10:36 AM
Hi,
you will not get a 1 in second case.
just think over again. what you are trying is in the first instance trying to see if the '(' is part of the string. which is yes, so it goes in ans set result to 1.
But in the second case you set result to 0 only when the string shouldn't contain '('. But since in your case it contains '(' it won't go in.
‎2004 Sep 02 11:21 AM
Actually the logic in the first post was completely wrong but my second post shows how I solved my own problem. Just didn't have my eyes open is all
‎2004 Sep 03 7:18 AM
Hello Craig,
Use following statement. It works allways.
if ls_text CP '('.
do soething.
endif.
BR
Michael
‎2004 Sep 04 6:30 AM
Hi,
There is one more option, this will also work
IF char CN '+-*/=~#^[]\&%$@.,;:"!}{'.
-- do the job --
ENDIF
Prabhu Rajesh.