1. ...
INTO wa
2. ...
INTO CORRESPONDING FIELDS OF wa
3.
... INTO (f1, ..., fn)
4.
... INTO TABLE itab
5.
... INTO CORRESPONDING FIELDS OF TABLE itab
6.
... APPENDING TABLE itab
7. ... APPENDING CORRESPONDING FIELDS OF TABLE itab
With the statement SELECT
or FETCH this statement determines
the target area into which the data is to be read. If no data is read, the target area remains unchanged.
The result set is transported to the target area field by field. This means that the ABAP Dictionary data types of the result fields must correspond to the ABAP data types of the target fields as follows:
Result field | Target field |
Dict. data type | ABAP data type |
ACCP | C or N |
CHAR | C, STRING |
CLNT | C, STRING |
CUKY | C, STRING |
CURR | I, P or F |
DEC | I, P or F |
DATS | D |
FLTP | F |
INT1 | I, P or F |
INT2 | I, P or F |
INT4 | I, P or F |
LCHR | C |
LRAW | X |
LANG | C, STRING |
NUMC | C or N |
PREC | I, P or F |
QUAN | I, P or F |
RAW | X, XSTRING |
RAWSTRING | X, XSTRING |
SSTRING | C, STRING |
STRING | C, STRING |
TIMS | T |
UNIT | C, STRING |
VARC | C, STRING |
If the ABAP data type of the target field is C or X, the contents of the result field are placed left-justified in the target field. If the target field is too short, the result value is truncated on the right.
If the ABAP data type of the target field is N, the contents of the result field are placed right-justified in the target field and filled with zeros if required. If the target field is too short, the result value is truncated on the left.
If the ABAP data type of the target field is numeric, the target field must be long enough to hold the contents of the result field.
If a field in the result set contains a NULL value, the initial value of the ABAP data type corresponding to the field type is placed in the target area (see TABLES).
Depending on the database system, any violation of the correspondence rules can lead to a runtime error.
In a SELECT ... ENDSELECT loop, the target area is readdressed
in every iteration. If the target area is changed during the loop processing (for example by converting a field symbol), this is taken into account.
... INTO wa
Places the result set in the target area wa line by line.
The way how the result set is transported to the target area is determined by the SELECT clause:
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs.See Open SQL and Unicode.
If the result of a selection is a table, the data is retrieved in a processing loop introduced by
SELECT and concluded by ENDSELECT.
The processing passes through the loop once for each line read. If the result is a single record, the closing ENDSELECT is omitted.
Output a list of all airlines (with short description and name):
DATA: wa TYPE scarr.
SELECT * INTO WA FROM scarr.
WRITE: / wa-carrid, wa-carrname.
ENDSELECT.
Output a list of all airlines (with short description and name):
DATA: BEGIN OF wa1,
client TYPE scarr-mandt,
carrid TYPE scarr-carrid,
carrname
TYPE scarr-carrname,
url TYPE
scarr-url,
rest(100),
END
OF wa1.
SELECT * INTO wa1 FROM SCARR.
WRITE: / wa1-carrid, wa1-carrname.
ENDSELECT.
Output a list of all airlines (with short description and name):
DATA: BEGIN OF wa2,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
END
OF wa2.
END OF WA2.
SELECT carrid carrname
INTO wa2
FROM scarr.
WRITE: / wa2-carrid, wa2-carrname.
ENDSELECT.
... INTO CORRESPONDING FIELDS OF wa
Places the result set in the target area wa line by line.
Each field of the result set is transported to the field of the same name in wa. If no such field exists, this is ignored, and no runtime error occurs.
If the result of a selection is a table, the data is retrieved in a processing loop introduced by
SELECT and concluded by ENDSELECT.
The processing passes through the loop once for each line read. If the result is a single record, the closing ENDSELECT is omitted.
Output a list of all airlines (with short description and name):
DATA: carrier TYPE scarr.
DATA: tabname(10).
SELECT CARRID CARRNAME
tabname = 'SCARR'.
FROM SCARR.
SELECT *
INTO CORRESPONDING FIELDS OF carrier
FROM (tabname).
WRITE: / carrier-carrid, carrier-carrname.
ENDSELECT.
... INTO (f1, ..., fn)
Places the result set in the target area (f1, ..., fn).
The fields of the result set are transported to the target fields fi
from left to right. INTO (f1, ..., fn) is allowed only
if a list with n elements is also specified in the SELECT clause.
If the result of a selection is a table, the data is retrieved in a processing loop introduced by
SELECT and concluded by ENDSELECT.
The processing passes through the loop once for each line read. If the result is a single record, the closing ENDSELECT is omitted.
Output a list of all airlines (with short description and name):
DATA: carrid TYPE scarr-carrid,
carrname
TYPE scarr-carrname.
CARRNAME LIKE SCARR-CARRNAME,
SELECT
carrid carrname
INTO (carrid, carrname)
FROM scarr.
WRITE: / carrid, carrname.
ENDSELECT.
... INTO TABLE itab
Works like ... INTO wa, except that the selected data
is not placed in the internal table itab
line by line, but in one single operation. In this case,
SELECT does not introduce a processing loop, so there
can be no ENDSELECT statement.
The old contents of itab are overwritten. Fields of the
internal table itab which are not filled are initialized
based on their ABAP data type (see DATA).
In some cases, the syntax rules that apply to Unicode programs are different than those for non-Unicode programs.See Open SQL and Unicode.
Output a list of all airlines (with short description and name):
DATA: ITAB TYPE STANDARD TABLE OF scarr WITH NON-UNIQUE
DEFAULT KEY INITIAL SIZE 100,
wa_itab TYPE scarr.
WA_ITAB TYPE SCARR.
SELECT * INTO TABLE itab FROM scarr.
LOOP AT itab INTO wa_itab.
WRITE: / wa_itab-carrid, wa_itab-carrname.
ENDLOOP.
... PACKAGE SIZE n
Works like ... INTO wa, except that the selected data
is not placed in the internal table itab line by line,
but in packets of n lines. The old contents of itab are overwritten.
If the result of the selection is a table, the data is retrieved in a processing loop introduced by
SELECT and concluded by ENDSELECT. The processing passes through the loop once for each line read.
Output a list of all airlines (with short description and name):
DATA: itab TYPE STANDARD TABLE OF SCARR WITH NON-UNIQUE
DEFAULT KEY INITIAL SIZE 10.
FIELD-SYMBOLS: <FS> TYPE scarr.
SELECT * INTO TABLE
itab PACKAGE SIZE 20 FROM scarr.
LOOP AT itab ASSIGNING <FS>.
WRITE: / <FS>-carrid, <FS>-carrname.
ENDLOOP.
ENDSELECT.
... INTO CORRESPONDING FIELDS OF TABLE itab
Works like ... INTO CORRESPONDING FIELDS OF wa, except
that the selected data is not placed in the internal table itab
line by line, but in a single operation. In this case,
SELECT does not introduce a processing loop, so there
can be no ENDSELECT statement.
The old contents of itab are overwritten. Fields of the
internal table itab which are not filled are initialized
based on their ABAP data type (see DATA).
... PACKAGE SIZE n
Works as with ... INTO TABLE itab.
... APPENDING TABLE itab
Works like ... INTO TABLE itab, except that the read lines
are appended to the old contents of the internal table itab.
... PACKAGE SIZE n
Works as with ... INTO TABLE itab.
... APPENDING CORRESPONDING FIELDS OF TABLE itab
Works like ... INTO CORRESPONDING FIELDS OF TABLE itab,
except that the read lines are appended to the old contents of the internal table itab.
... PACKAGE SIZE n
Works as with ... INTO TABLE itab.
If cursor processing is introduced with OPEN CURSOR, the sequence of FETCH statements may contain different INTO clauses - within a strict context. The following rules apply:
Performance:
Entering a Target Area