... FROM { {dbtab [AS tabalias]}
| join
| {(dbtab_syntax) [AS tabalias]} }
[UP TO n ROWS]
[CLIENT SPECIFIED]
[BYPASSING BUFFER]
[CONNECTION {con|(con_syntax)}] ... .
1.... dbtab [AS tabalias]
2.... join
2.... (dbtab_syntax) [AS tabalias]
1.... UP TO n ROWS
2.... CLIENT SPECIFIED
3.... BYPASSING BUFFER
4.... CONNECTION {con|(con_syntax)}
Entries in source specify whether a
database table or a
view, or if many database tables or views are accessed by a
join expression. Optional additions execute the
client handling, specify whether the
SAP buffering is avoided, and determine the maximum number of rows to be read.
... dbtab [AS tabalias]
A database table or a view defined in the ABAP Dictionary can be specified for dbtab. An alternative table name tabalias can be assigned to the database table or the view using the addition AS. This name can have a maximum of 14 characters and is valid during the SELECT statement only. It must be used in all other locations instead of the actual name.
If a database table or a view appears multiple times after FROM in a join expression, you must use the alternative name to avoid ambiguities.
Reading from the database table spfli and assigning the alternative name s. In this case, the specification of the prefix s~ after ORDER BY can also be omitted, because only one database table is read and the column name carrid is unique. The prefix spfli~ can no longer be used when assigning the alternative name.
DATA wa TYPE spfli.
SELECT *
FROM spfli AS s
INTO wa
ORDER BY s~carrid.
WRITE: / wa-carrid, wa-connid.
ENDSELECT.
... join
Specification of a Join expression that links several database tables or views with one another.
... (dbtab_syntax) [AS tabalias]
Instead of static specifications, a data object dbtab_syntax can be specified in brackets. When executing the statement, it must contain the syntax displayed during the static specification. The data object dbtab_syntax can be a character-type data object or an internal table with a character-type data object. The syntax in dbtab_syntax is not case-sensitive as in the ABAP Editor. The syntax can be spread over many rows when specifying an internal table.
The addition AS can be specified only if dbtab_syntax exclusively contains the name of a single database table or a view. The addition has the same meaning for this database table or view as in a static specification.
When specifying the syntax in dbtab_syntax, the following restrictions apply:
Dynamic specification of the inner joins. The column specification after SELECT is also dynamic.
PARAMETERS: p_cityfr TYPE spfli-cityfrom,
p_cityto TYPE spfli-cityto.
DATA: BEGIN OF wa,
fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.
DATA itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY fldate carrname connid.
DATA: column_syntax TYPE string,
dbtab_syntax TYPE string.
column_syntax = `c~carrname p~connid f~fldate`.
dbtab_syntax = `( ( scarr AS c `
& ` INNER JOIN spfli AS p ON p~carrid = c~carrid`
& ` AND p~cityfrom = p_cityfr`
& ` AND p~cityto = p_cityto )`
& ` INNER JOIN sflight AS f ON f~carrid = p~carrid `
& ` AND f~connid = p~connid )`.
SELECT (column_syntax)
FROM (dbtab_syntax)
INTO CORRESPONDING FIELDS OF TABLE itab.
LOOP AT itab INTO wa.
WRITE: / wa-fldate, wa-carrname, wa-connid.
ENDLOOP.
... UP TO n ROWS
This addition restricts the number of rows in the result set. A data object of the Type i is expected for n. A positive number in n indicates the maximum number of rows in the result set. If n contains the value 0, all selected rows are passed to the result set. If n contains a negative number, an exception that cannot be handled is raised.
If the addition ORDER BY is also specified, the rows of the hit list are sorted on the database server and only the number of sorted rows specified in n are passed to the result set. If the addition ORDER BY is not specified, n is filled with any number of rows in the result set that meet the WHERE condition.
... CLIENT SPECIFIED
This addition switches off the automatic client handling of Open SQL. When specifying a single database table or a single view, the addition must be inserted directly after dbtab of the join condition. When specifying a join expression, it must be inserted after the last addition ON of the join condition.
When using the addition CLIENT SPECIFIED, the first column
of the client-dependent database tables can be specified in the WHERE condition to determine the
client identifier. In the addition ORDER BY, the column can be sorted explicitly according to client identifier.
If the addition CLIENT SPECIFIED is specified, but the
client ID in the WHERE condition is not, the SELECT statement circumvents the
SAP buffering.
... BYPASSING BUFFER
This addition causes the SELECT statement to avoid the
SAP buffering and to read directly from the database and not from the buffer on the
application server.
... CONNECTION {con|(con_syntax)}
This addition is for internal use only.
It cannot be used in application programs
The Open SQL command is not executed on the standard database but on the specified secondary database connection. The database connection can be specified statically with con or dynamically as the content of con_syntax, where the field con_syntax must belong to the type c or string. The database connection must be specified with a name that is in column CON_NAME in table DBCON.
The addition CONNECTION must be specified immediately after the name of the database table or after the addition CLIENT SPECIFIED.
If the Open SQL command is to be possible on a secondary database connection, the table definitions in the connection must be the same as those on the standard database.