Inline declarations & modern Open SQL
What you'll learn
Modern Open SQL uses a comma-separated field list and an inline @DATA(...) target, which makes INTO CORRESPONDING FIELDS unnecessary when the table mirrors the list.
- Use @DATA(...) to declare the target inline at the point of the SELECT.
- Comma-separated field list is required in modern (strict) Open SQL.
- Host variables need the @ escape in WHERE and INTO.
Clean ABAP wants inline declarations wherever they shorten code without obscuring intent. In Open SQL that means a comma-separated field list and an inline @DATA(...) host variable: SELECT matnr, mtart FROM mara WHERE ... INTO TABLE @DATA(lt_mara). The variable is declared exactly where it is filled, so there is no separate DATA block to keep in sync.
The key insight is that INTO CORRESPONDING FIELDS OF TABLE becomes unnecessary when the inline target mirrors the SELECT list, because the compiler builds the target's structure from the projection itself — the columns line up by position and name by construction. CORRESPONDING was only ever needed to reconcile a hand-declared structure with a different field order; remove the mismatch and you remove the need.
Two syntax details matter against 758: the field list is comma-separated (note the comma after matnr), and host variables in the WHERE and INTO clauses must be escaped with @. These are not optional stylistic flourishes — the modern strict Open SQL syntax requires them.
Key points
- Use @DATA(...) to declare the target inline at the point of the SELECT.
- Comma-separated field list is required in modern (strict) Open SQL.
- Host variables need the @ escape in WHERE and INTO.
- Drop INTO CORRESPONDING FIELDS when the inline table mirrors the field list exactly.
Examples
A separate DATA block and INTO CORRESPONDING FIELDS to reconcile a hand-declared table.
ABAPdata: lt_mara type standard table of mara,
ls_mara type mara.
select matnr mtart from mara
into corresponding fields of table lt_mara
where mtart = 'FERT'.The inline @DATA target mirrors the comma-separated list, so CORRESPONDING is unnecessary.
ABAPselect matnr, mtart
from mara
where mtart = 'FERT'
into table @data(lt_mara).Pitfalls
- Forgetting the comma between fields in the new SELECT list, or the @ escape on host variables.
- Keeping INTO CORRESPONDING FIELDS out of habit when the inline target already mirrors the list.
Source notes: clean-core-curriculum §3.2
Ask Claude
Build a prompt from this lesson + your question and open a fresh Claude chat with it pre-filled — handy for adapting a before/after pattern to your own object.