Ansicht
Dokumentation

ABAPFIND_ITAB - FIND ITAB

ABAPFIND_ITAB - FIND ITAB

General Material Data   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

FIND IN TABLE itab

Short Reference



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 line-by-line 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 lines in the table must be character-like or byte-like, depending on the addition CHARACTER or BYTE MODE. Character strings or byte strings that cover multiple table lines are not found.

The table_range addition can be used to restrict the search range in the table. When making replacements in the individual table lines, the other additions generally have the same meaning as the statement FIND for elementary character or byte strings. Here, a further addition MATCH LINE also returns the line number of any occurrence.

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 range, or if the end of the search range was reached. The search result is communicated by setting sy-subrc.

In string processing for line types of fixed length, trailing blanks are respected.

If the internal table is empty, a search is never successful and sy-subrc is set to 4 with one exception: A search for a obsolete POSIX regular expression that matches an empty string sets sy-subrc to 0 and behaves as if the internal table contained an empty first line by returning 1 for MATCH LINE and 0 for MATCH OFFSET and MATCH LENGTH.

Notes

  • FIND IN TABLE can be used to search tables with structured line types for character strings, if the structure only contains flat character-like components. Every line is then handled in the same way as a field of type c.
  • Searching using FIND IN TABLE produces better performance than running a LOOP and using FIND to search the individual lines.
  • For searching multiple lines, the lines can be converted to a string by using the concatenation function concat_lines_of or the statement CONCATENATE LINES OF. It must be ensured that trailing blanks are handled correctly.

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

Reading of a text into an internal table in ITF format and search for the first string "ABAP" or "XML". The positions the occurrence are written in variables. The line type of the internal table is interpreted as a single field of the type c despite being a structured type.

Exceptions

Catchable Exceptions

CX_SY_RANGE_OUT_OF_BOUNDS

  • Cause: Illegal offset or length specified in the addition SECTION OF.
    Runtime Error: REFI_WRONG_SECTION

CX_SY_TAB_RANGE_OUT_OF_BOUNDS

  • Cause: Illegal offset or length specification in the addition of FROM ... OFFSET ... TO OFFSET.
    Runtime Error: INVALID_TABLE_RANGE

CX_SY_INVALID_REGEX

  • Cause: Invalid expression after the addition PCRE$|REGEX.
    Runtime Error: INVALID_REGEX






Vendor Master (General Section)   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.

Length: 6621 Date: 20240424 Time: 070248     sap01-206 ( 77 ms )