Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in using find command - Need Pointers

Former Member
0 Kudos
93

Hi Experts,

I am using FIND Command to search for a string in fields of internal table.

Example:

Search string : test

Code

Loop at itab into wa.

wa = 'test record found or not '.

find all occurrences of 'test' in wa. (This gives me correct result)

but in scenario like this:

wa = 'testing is in progress'

find all occurrences of 'test' in wa.

it gives me a sy-subrc 0 as word 'test' is found in word 'testing'.

i would like to ignore this record for further processing.

Any suggestions on what should i do to search for the exact keword in the string ?

Thanks

Bhanu

1 ACCEPTED SOLUTION

former_member156446
Active Contributor
0 Kudos
62

Here is the sample code tested and found working:

data:
  a type string,
  r TYPE string VALUE '(^|[[:blank:][:cntrl:][:punct:]])test([[:blank:][:cntrl:][:punct:]]|$)',
  result_tab type match_result_tab.


FIND ALL OCCURRENCES OF REGEX r IN
 'test.asaa. testin atest bu;lll test111.test' RESULTS result_tab.

3 REPLIES 3

former_member156446
Active Contributor
0 Kudos
63

Here is the sample code tested and found working:

data:
  a type string,
  r TYPE string VALUE '(^|[[:blank:][:cntrl:][:punct:]])test([[:blank:][:cntrl:][:punct:]]|$)',
  result_tab type match_result_tab.


FIND ALL OCCURRENCES OF REGEX r IN
 'test.asaa. testin atest bu;lll test111.test' RESULTS result_tab.

0 Kudos
62

Hi J@Y ,

It works fine for me thanks for looking into it.

One question how did you found out the string (^|[[:blank:][:cntrl:][:punct:]])

0 Kudos
62

SAP Help

help.sap.com