Multiple choice technology programming languages

An internal table icode contains the following entries: Field1 Field2 -------------- John 12345 Alice 23478 Sam 54321 john 50000 DATA: BEGIN OF ICODE OCCURS 0, FIELD1(5), FIELD2(5), END OF ICODE. READ TABLE ICODE WITH KEY FIELD1 = 'John' BINARY SEARCH. Why does executing the above code return a sy-subrc of 4?

  1. Icode-field2 must be a numeric field.

  2. The internal table has an incorrect structure.

  3. Both internal table fields must be used in the search.

  4. The internal table must be sorted first.

  5. 'John' should not be capitalized.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The BINARY SEARCH addition in READ TABLE requires the internal table to be sorted in ascending order by the search key fields. Since the table is unsorted (note: 'John' appears before 'Alice' and also appears twice with different cases), the binary search algorithm fails and returns sy-subrc = 4 (not found). Binary search uses a divide-and-conquer algorithm that only works correctly on sorted data.