Skip to Content
0
Jan 14, 2011 at 11:59 AM

String Functions, count, find, match; is unknown or protected or private

126 Views

Hi,

I am trying to execute the demo program available at http://help.sap.com/abapdocu_702/en/abenstring_function_find_abexa.htm

the code simply copied and pasted in abap workbench is:

REPORT demo_find_and_match.

PARAMETERS: text TYPE c LENGTH 120 LOWER CASE
            DEFAULT `Cathy's cat with the hat sat on Matt's mat.`,
            regx TYPE c LENGTH 120 LOWER CASE
            DEFAULT `\<.at\>`.

CLASS demo DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS main.
ENDCLASS.

CLASS demo IMPLEMENTATION.
  METHOD main.
    DATA: result TYPE i,
          substr TYPE string.
    WRITE / text.
    NEW-LINE.
    result = count( val   = text
                    regex = regx ).
    DO result TIMES.
      result = find( val   = text
                     regex = regx
                     occ   = sy-index ).
      substr = match( val   = text
                      regex = regx
                      occ   = sy-index ).
      result = result + 1.
      WRITE AT result substr.
    ENDDO.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  demo=>main( ).

when i am trying to do Control+F2,

it is giving the error as:

Method 'COUNT' is unknown or protected or private. Method 'FIND' is unknown or protected or private. Method 'MATCH' is unknown or protected or private.

what could be the problem.