‎2009 Jun 04 11:11 AM
Dear All,
I have a requirement i.e I need to search for a particular word in a string as a condition. I can use the Offsetting but then thing is then word can be at any place in the string where we cannot use offsetting i think so.
Wat is the syntax to handle such a requirement.
Please give any sample code if possible.
Thanks
NSK
Edited by: shashikanth naram on Jun 4, 2009 12:11 PM
‎2009 Jun 04 11:13 AM
Hi,
You can use FIND statement.
Press F1 on FIND for examples
Regards
‎2009 Jun 04 11:14 AM
‎2009 Jun 04 11:14 AM
hi,
data: str1(20) value 'the whole string', str2(5).
if str1 CS str2.
"found word from str2 string....
else
endif.
regards,darek
‎2009 Jun 04 11:16 AM
Hi,
To find a particulat string u can use this example coding,
if itab-field1 CA 'ABCDEFGHIJKLMONQRSTUVWXYZ0123456789+-*/$@^&()<>&~.!'.
replace all occurrences of '#' in itab-kverm1 with space "any field which you want to select
write: /5 itab-field1
endif.
endloop.
or
if itab-field1 CO '*'.
replace all occurrences of '*' in itab-field1 with space "any field which you want to select
write: /5 itab-field1
endif.
endloop.regards,
Nikhil.
‎2009 Jun 04 11:19 AM
Cant you use:
IF string CS word
ENDIF.
Can you please explain ur requirmenet more clearly?
‎2009 Jun 04 11:20 AM
‎2009 Jun 04 11:24 AM
Hi,
This piece of code might help you out.
REPORT ZNIT_REPORT1.
data: str1 type string value 'Hello!!! this is nitesh',
word(10) value 'nitesh'.
if str1 CS word.
write 'word is there'.
else.
write 'word is not there'.
endif.Thanks.
Nitesh
‎2009 Jun 04 11:28 AM
use 'CS' operator.
or you can use 'FIND' also .
use f1 help for more documentation and use of both.
‎2009 Jun 04 11:37 AM
Hello Shashikanth,
Here is the sample program which works fine.
Thanks
REPORT ztest_notepad.
DATA:str_data TYPE string VALUE 'Venkat is a good guy'.
IF str_data CS 'good'.
WRITE str_data.
ELSE.
WRITE 'No'.
ENDIF.
‎2009 Jul 02 10:23 AM
try this code...
data: l_str type string.
data: l_str1 type string.
data: l_str2 type string.
l_str = 'Account determination for payment reference401'.
if l_str+43(1) NE ''.
l_str1 = l_str+0(43).
l_str2 = l_str+43(3).
concatenate l_str1 l_str2 into l_str1 separated by space.
endif.