Skip to content

Avoid CROSS JOIN in ABAP SQL Queries ​

WarningPerformance & Database#EC NO_CROSS_JOINRemote Enabled

Overview ​

Avoid CROSS JOIN in ABAP SQL queries.

ATC Finding Message: Avoid CROSS JOIN; cartesian products cause heavy database and memory load

Rationale ​

A CROSS JOIN produces the cartesian product of two tables (M * N records) without join conditions. On non-trivial tables, this leads to exponential row proliferation, database memory exhaustion, and query timeouts.

Standard: Always connect joined tables with explicit ON conditions using INNER JOIN or LEFT OUTER JOIN.

Non-Compliant ​

abap
" Cartesian product: M * N rows
SELECT FROM t000 CROSS JOIN t001 FIELDS t000~mandt INTO TABLE @DATA(lt_data).

Compliant ​

abap
" Explicit ON join condition
SELECT FROM t000
  INNER JOIN t001 ON t000~mandt = t001~mandt
  FIELDS t000~mandt
  INTO TABLE @DATA(lt_data).

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.