SAP / SAP Beginner (0 to 2 yrs) Interview questions
How do you retrieve data from a database table using Open SQL?
The SELECT statement, combined with an INTO clause specifying where the result
should go (a single work area, or an internal table for multiple rows), is the standard way to read from a
database table in ABAP.
" single row SELECT SINGLE * FROM kna1 INTO @DATA(ls_customer) WHERE kunnr = '0000001234'. " multiple rows SELECT * FROM kna1 INTO TABLE @DATA(lt_customers) WHERE land1 = 'US'.
SELECT SINGLE is used when you expect (or only want) at most one matching row, while a plain
SELECT ... INTO TABLE fetches every matching row into an internal table for further processing.
Modern ABAP syntax (using the @ prefix for host variables and inline DATA(...)
declarations) is the current recommended style over older, more verbose declaration patterns.
More Related questions...