ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Internal Tables →  Processing Statements for Internal Tables → 

FIND IN TABLE itab  Syntax Diagram

Short Reference

Syntax

FIND [{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF] pattern
  IN TABLE itab [table_range]
  [IN {CHARACTER|BYTE} MODE]
  [find_options]
.

Effect

The internal table itab is searched row-by-row for the character strings or byte strings specified in pattern. itab is a functional operand position.

itab must be a standard table with no secondary table keys. The rows in the table must be character-like or byte-like, depending on the CHARACTER or BYTE MODE addition. Character strings or byte strings that cover multiple table rows are not found.

The table_range addition can be used to restrict the search range in the table. When replacing, the other additions generally have the same significance as the FIND statement for elementary character or byte strings, whereby a further addition MATCH LINE also returns the row number of any location found.

The search is terminated if the search pattern was found for the first time, or if all search patterns were found in the entire search area, or if the end of the search area was reached. The search result is communicated by setting sy-subrc.

In string processing with row types of fixed length, trailing blanks are respected.

Note

Searching using FIND IN TABLE produces better performance than running a LOOP and using FIND to search the individual rows.

System Fields

sy-subrc Meaning
0 The search pattern was found at least once in the search range.
4 The search pattern was not found in the search range.

The values of sy-tabix and sy-fdpos are not changed.

Example

Searches for all occurrences of Donald's nephews in an internal table and save the results in the table results.

DATA: itab    TYPE TABLE OF string.

...

FIND ALL OCCURRENCES OF REGEX '\b(Huey|Dewey|Louie)\b'
  IN TABLE itab
  RESPECTING CASE
  RESULTS DATA(results).

Exceptions

Catchable Exceptions

CX_SY_RANGE_OUT_OF_BOUNDS

CX_SY_TAB_RANGE_OUT_OF_BOUNDS

CX_SY_INVALID_REGEX




Continue
FIND IN TABLE - table_range
FIND IN TABLE - options