While READ statement is valid, ABAP has opened a new approach to fetching values from the internal table based on conditions. This is a more simplistic approach aiming at compact coding.
Reading a table with index can be simplified as follow –
<work_area> = <internal_table>[ <index_number> ] .
Reading a table with key can be wriiten as –
<work_area> = <internal_table>[ <column_1> = <condition_1> <column_2> = <condition_2> ] .
Checking an entry using TRANSPORTING NO FIELDS can be replaced with –
IF line_exists( <internal_table>>[ <column_1> = <condition_1>])
Here predicate function line_exists is used. Another such function is line_index which can be used to get table index.
The only caveat using these expressions is that usual sy-subrc will not cover the bases. Errors would be expected to be captured with a CX_SY_ITAB_LINE_NOT_FOUND exception instead.
~S
Recent Comments