ABAPFIND_TABLE_RANGE - FIND TABLE RANGE

General Material Data   ABAP Short Reference  
This documentation is copyright by SAP AG.

FIND IN TABLE - table_range

Short Reference



Syntax

... [FROM lin1 [OFFSET off1]]
    [TO   lin2 [OFFSET off2]] ... .


Effect

: This addition limits the search in the statement FINDIN TABLE to the table section specified in lin1, off1, lin2 and off2. Without this addition, the program searches the whole table, line by line. lin1, off1, lin2 and off2 arenumerical expression positions of operand type i.

The table section begins in the line lin1 after theoffsetoff1, and ends in the line lin2 before the offset off2. If FROM is specifiedwithout 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 line lin2.

The value of lin1 must be greater than or equal to 1, and the value of lin2 must be greaterthan or equal to the value of lin1, and both must refer to valid table lines. The values of off1and off2 must be greater than or equal to 0 and be within the respective row length. If lin1and lin2 indicate the same row, the value ofoff2 must be greater than or equal to the value of off1 . Both offsets may refer to the end of the line.

Note

: This addition is also used in the statement REPLACE IN TABLE.

Example

: Count 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.
  READ TABLE itab INDEX mlin ASSIGNING <line>.
  IF moff >= STRLEN( <line> ).
    mlin = mlin + 1.
    IF mlin > LINES( itab ).
      EXIT.
    ENDIF.
    moff = 0.
  ENDIF.
  FIND REGEX '\b(Huey|Dewey|Louie)\b'
       IN TABLE itab FROM mlin OFFSET moff
       RESPECTING CASE
       MATCH LINE mlin
       MATCH OFFSET moff
       MATCH LENGTH mlen.
  moff = moff + mlen.
ENDWHILE.


Addresses (Business Address Services)   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.


Length: 3762 Date: 20120522 Time: 055849     triton ( 123 ms )