When you use this statement you need to know how the internal table has been declared, if reading an internal table. Will affect how you write the READ statement code. The READ statement is the fastest way to access records of an internal table. Using index is the fastest form of the read statement. 3x faster than a hash table. Can be 14x faster than using a normal table key. We do not always know what the index number is of the record we want to read. Nearly always end up using table keys. If you use key access, specify WITH KEY and write key fields. With a non-unique key, the READ statement reads sequentially through your table. You'll get the first record that appears in your table that matches your key. READ statement can also be used for sorted and hash tables. When you specify key fields to use in search, system will use binary search for sorted tables and use a hash algorithm for hash tables. If the fields you choose to use are not key fields, the system will carry out sequential search for both sorted and hash tables.
TABLES zemployees. *New Way of defining Internal Tables *Declare a Line Type TYPES: BEGIN OF line01_typ, surname LIKE zemployees-surname, dob LIKE zemployees-dob, END OF line01_typ. *Declare the 'Table Type' based on the Line Type. TYPES itab02_typ TYPE STANDARD TABLE OF line01_typ. *Declare the table based on the 'Table Type' DATA itab02 TYPE itab02_typ. *Declare the Work Area to use with our Internal Table DATA wa_itab02 TYPE line01_typ. SELECT * FROM zemployees INTO CORRESPONDING FIELDS OF TABLE itab02. READ TABLE itab02 INDEX 5 INTO wa_itab02. READ TABLE itab02 INTO wa_itab02 WITH KEY surname = 'SMITH'. *************************************** * For table with header line TABLES zemployees. *Internal Table with Header line DATA: BEGIN OF itab01 OCCURS 0, employee LIKE zemployees-employee, surname LIKE zemployees-surname, forename LIKE zemployees-forename, title LIKE zemployees-title, dob LIKE zemployees-dob, los TYPE i VALUE 3, END OF itab01. * For standard table with non-unique key READ TABLE itab01 INDEX 5. * Read access for a table key READ TABLE itab01 WITH KEY employee = 10000007.