Ansicht
Dokumentation

ABAPFROM_CLAUSE - FROM CLAUSE

ABAPFROM_CLAUSE - FROM CLAUSE

Vendor Master (General Section)   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.
SAP E-Book

SELECT, FROM

Short Reference



... FROM ${ ${data_source $[AS tabalias$]$}
         $| join
         $| ${(source_syntax) $[AS tabalias$]$} $}
        $[ client_handling $] ...

Alternatives:

1. ... data_source

2. ... join

3. ... (source_syntax)

Addition:

... AS tabalias

Effect

The specifications after FROM determine whether a query accesses a DDIC database table, a DDIC view, a CDS entity, an SQL hierarchy, or an internal table as a data source data_source, or whether multiple data sources are accessed in a join expression. The optional addition AS defines an alias name for the data source. The optional additions client_handling affect how client handling is performed.

Alternative 1

... data_source


Effect

Specification of a single data source data_source.

Note

If a data source is specified multiple times after FROM in a join expression, an alias name tabalias must be defined after AS to avoid ambiguities.

Example

Specification of the DDIC database table SCARR as the only data source of a SELECT statement.

Alternative 2

... join


Effect

Specifies a join expression that joins multiple data sources with one another.

Example

Specification of the DDIC database tables SCARR and SPFLI in a join expression.

Alternative 3

... (source_syntax)


Effect

Instead of static specifications, a data object source_syntax can be specified in parentheses. When the statement is executed, the data object must contain the syntax shown in the static specification. The data object source_syntax can be a character-like data object or a standard table with a character-like row type. The syntax in source_syntax is not case-sensitive. When an internal table is specified, the syntax can be distributed across multiple rows. Invalid syntax raises a catchable exception from the class CX_SY_DYNAMIC_OSQL_ERROR.

The addition AS used to specify an alias name statically can be specified only if source_syntax contains only the name of a single data source. The addition has the same meaning for this data source as when specified statically. In source_syntax, static attributes or constants of a class cannot be accessed from outside if the class has a static constructor that has not yet been executed. See SQL Injections Using Dynamic Tokens.

Notes

  • If source_syntax is an internal table with a header line, the header line and not the table body is evaluated.
  • The addition AS can be used as part of the dynamic syntax in source_syntax without restrictions.
  • More specifically, if AS is specified statically outside the dynamic specification, source_syntax cannot contain any path expressions.
  • The class CL_ABAP_DYN_PRG contains methods that support the creation of correct and secure dynamic code.

Example

Displays the flight connections (flight date, airline name, and flight number) for a departure city and a destination city. The FROM clause, including any inner joins is dynamic. The column specified after SELECT is also dynamic. When specified dynamically, the input values are specified indirectly using the name of the respective data object and are not chained directly. Otherwise, a special security check would be required for this input.

SELECT, Dynamically Specified Tokens

Addition

... AS tabalias

Effect

An alias name tabalias can be assigned to the data source using the addition AS. This name is valid during the SELECT statement only, and in all other positions where this specified data source is addressed, and the actual name does not need to be used.

The alias name tabalias must follow the naming conventions for internal program names and the name table_line cannot be used. This is checked in strict mode of the syntax check from Release .

Notes

  • An alias name tabalias prevents the original name data_source from being used and this also applies to dynamic tokens in principle. This is not checked, however, until the introduction of the strict modes in the syntax check from Release and may raise an exception.
  • If an alias name is to be named exactly like an addition of the SELECT statement exactly, it may be necessary to prefix it with the escape character !.
  • A path expression in the data source of the FROM clause should have an alias name defined with AS. This is checked in strict mode from Release .
  • Outside of the strict syntax check mode from Release , an alias can also contain the minus character (-).

Example

Definition of alias names for two data sources of a join expression and using them in the SELECT list and in the ORDER BY clause.






CPI1466 during Backup   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

Length: 8754 Date: 20240426 Time: 115340     sap01-206 ( 130 ms )