What does it do? This addition limits the search in the statementFIND IN TABLE to the table section specified in lin1, off1, lin2 and off2. Without this addition, the program searches the whole table, row by row. lin1, off1, lin2 and off2 are numerical expression positions of operand type i.
The table section begins in the row lin1 after theoffset off1, and ends in the row lin2 before the offset off2. If FROM is specified without OFFSET, the section implicitly begins at the start of lin1. If TO is specified without OFFSET, the range implicitly ends at the end of the row lin2.
The value of lin1 must be greater than or equal to 1, and the value of lin2 must be greater than or equal to the value of lin1, and both must refer to valid table rows. The values of off1 and off2 must be greater than or equal to 0 and be within the respective row length. If lin1 and lin2 indicate the same row, the value of off2 must be greater than or equal to the value of off1. Both offsets may refer to the end of the row.
Latest notes:This addition is also used in the statementREPLACE IN TABLE.
Example ABAP Coding Counts the frequency with which one of Donald's nephews occurs in an internal table. In the example FIND IN itab, the same result can be achieved more simply using the number of rows in results. DATA: itab TYPE TABLE OF string, cnt TYPE i, mlin TYPE i, moff TYPE i, mlen TYPE i.
FIELD-SYMBOLS <(><<)>line> TYPE string.
...
cnt = -1. mlin = 1. moff = 0. WHILE sy-subrc = 0. cnt = cnt + 1. ASSIGN itab[ mlin ] TO <(><<)>line>. IF moff >= STRLEN( <(><<)>line> ). mlin = mlin + 1. IF mlin > LINES( itab ). EXIT. ENDIF. moff = 0. ENDIF. FIND REGEX '(Huey|Dewey|Louie)' IN TABLE itab FROM mlin OFFSET moff RESPECTING CASE MATCH LINE mlin MATCH OFFSET moff MATCH LENGTH mlen. moff = moff + mlen. ENDWHILE.