The SELECT statement in SAP ABAP is used to retrieve data from database tables into internal tables or variables. It’s one of the most powerful and frequently used Open SQL statements in ABAP and helps interact with the underlying SAP database layer.
How SELECT Works in ABAP (Step-by-Step)
- Specify the columns to be fetched or use * for all columns.
- Mention the source table from which data will be retrieved.
- Optionally add a WHERE clause to filter data.
- Decide the target structure (single variable, work area, internal table).
- Process or display the results.
Form | Description | Use Case |
SELECT SINGLE | Fetches only 1 row | Fetching config or master data |
SELECT … INTO TABLE | Fetches multiple rows into internal table | Bulk data operations |
SELECT … ENDSELECT | Fetches row-by-row | When memory optimization is required |
SELECT COUNT(*) | Returns the number of rows | Aggregation or existence checks |
SELECT with JOIN | Combines rows from multiple tables | Getting related information in one call |