Skip to content

Modernize READ TABLE (Table Expressions & line_exists) ​

WarningClean ABAP & Modern SyntaxQuickFix Ready#EC PREF_TAB_EXPRRemote Enabled

Overview ​

Modernize READ TABLE (table expressions & line_exists).

ATC Finding Messages:

  • Prefer table expression itab[ ... ] over READ TABLE
  • Prefer line_exists( ... ) instead of READ TABLE ... TRANSPORTING NO FIELDS

Rationale ​

Legacy READ TABLE requires procedural work areas, field symbols, and error-prone sy-subrc checks. Modern ABAP provides table expressions (itab[ ... ]) for direct value and reference retrieval, and line_exists( ... ) for existence checks. Modernizing READ TABLE simplifies code, avoids mutable intermediary variables, and embeds seamlessly into functional expressions.

Non-Compliant ​

abap
READ TABLE lt_orders INTO ls_order WITH KEY order_id = lv_id.
READ TABLE lt_customers TRANSPORTING NO FIELDS WITH KEY customer_id = lv_id.
IF sy-subrc = 0.
  process( ).
ENDIF.

Compliant ​

abap
ls_order = VALUE #( lt_orders[ order_id = lv_id ] OPTIONAL ).
IF line_exists( lt_customers[ customer_id = lv_id ] ).
  process( ).
ENDIF.

Automated QuickFix ​

This rule provides an automated QuickFix directly in Eclipse ABAP Development Tools (ADT):

  1. Position the cursor on the flagged statement.
  2. Press Ctrl + 1 (Quick Assist).
  3. Select the automated refactoring to apply the clean syntax immediately.

Configuration & Thresholds ​

This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:

Parameter NameData TypeDefault ValueDescription & Guidance
USE_OPTIONALBooleantrueSuggest OPTIONAL addition in table expressions to prevent CX_SY_ITAB_LINE_NOT_FOUND dumps
CHECK_TAB_EXPRBooleantrueSuggest table expressions (lt_tab[ ... ]) instead of READ TABLE INTO
CHECK_LINE_EXISTSBooleantrueSuggest line_exists( ) instead of READ TABLE TRANSPORTING NO FIELDS

Suppression ​

To suppress findings for this rule, append the pseudo-comment to the statement:

abap
" Standard pseudo-comment:
... "#EC PREF_TAB_EXPR

" SAP CI_ prefix format:
... "#EC CI_PREF_TAB_EXPR

Technical Details ​

Released under the MIT License.