Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Internal Tables →  Processing Statements for Internal Tables →  FIND IN TABLE itab 

FIND IN TABLE - options

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


... [{RESPECTING|IGNORING} CASE] 
    [MATCH COUNT  mcnt]
    { {[MATCH LINE   mlin]
       [MATCH OFFSET moff]
       [MATCH LENGTH mlen]}
    | [RESULTS result_tab|result_wa] }
    [SUBMATCHES s1 s2 ...] ...

Effect

The addition MATCH LINE returns the number of the row in which the last substring was found using FIND IN TABLE in data object mlin. The following can be specified for mlin:

  • An existing variable that expects the data type i.
  • An inline declaration DATA(var). The declared variable has the data type i.

If the substring is not found, mlin retains its previous value or stays initial.

The remaining additions used for searching in the individual table rows have the same meaning as in the statement FIND for elementary character strings and byte strings.

If the addition RESULTS is used, the row numbers of each occurrence in the component LINE of the table row in question in result_tab or the row number of the last occurrence are also saved to result_wa and the rows in result_tab are sorted by the columns LINE, OFFSET, and LENGTH.


Example

Reads a text into an internal table in ITF format and searches for all strings "ABAP" and "XML". The table returned contains the positions of the occurrences. The row type of the internal table is interpreted as a single field of the type c despite being a structured type.

TYPES: 
  BEGIN OF result, 
    line     TYPE i, 
    offset TYPE i, 
    length TYPE i, 
  END OF result, 
  result_tab TYPE TABLE OF result WITH EMPTY KEY. 

DATA itf_tab TYPE tline_tab. 
IF cl_abap_docu_itf=>get_docu( EXPORTING id = 'SD' 
                                        langu = 'E' 
                                        object = 'ABENABAP_XML' 
                              IMPORTING itf = itf_tab ) = 0. 

  FIND ALL OCCURRENCES OF REGEX 'ABAP|XML' 
       IN TABLE itf_tab 
       RESPECTING CASE 
       RESULTS DATA(results). 

  IF sy-subrc = 0. 
    cl_demo_output=>display( CORRESPONDING result_tab( results ) ). 
  ENDIF. 
ENDIF.