Ansicht
Dokumentation

ABAPSELECT_DATA_SOURCE - SELECT DATA SOURCE

ABAPSELECT_DATA_SOURCE - SELECT DATA SOURCE

BAL Application Log Documentation   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.
SAP E-Book

SELECT, FROM data_source

Short Reference



...  dbtab $|view  $[WITH PRIVILEGED ACCESS$]
   $| cds_entity$[ sql_para$]$[sql_path$]$|$[ WITH PRIVILEGED ACCESS$]
   $| +cte$[sql_path$]
   $| hierarchy_data
   $| @itab
   $| cds_system_entity

Alternatives:

1. ... dbtab $|view  $[WITH PRIVILEGED ACCESS$]

2. ... cds_entity$[sql_para$]$[sql_path$]$|$[ WITH PRIVILEGED ACCESS$]

3. ... +cte$[sql_path$]

4. ... hierarchy_data

5. ... @itab

6. ... cds_system_entity

Effect

Specifies an individual DDIC database table dbtab, DDIC view view, non-abstract CDS entity cds_entity, a common table expression +cte, hierarchy data, an internal table @itab, or a CDS system entity in the FROM clause of a query.

Regarding views, there is the restriction that only those whose key fields are located together at the beginning of the view can be accessed.

Alternative 1

... dbtab
$|view  $[WITH PRIVILEGED ACCESS$]


Addition:

... WITH PRIVILEGED ACCESS

Effect

Specifies a DDIC database table dbtab or a DDIC view or an external DDIC view view. DDIC views on which reads can be performed using SELECT are DDIC database views and DDIC projection views.

Notes

  • If a CDS view is defined as a replacement object for a DDIC database table or DDIC database view specified as a data source, the SELECT statement accesses the CDS view and not the DDIC database table or the DDIC database view. In this case, it is recommended that the CDS view is used as a data source if possible.

Example

Reading of the data of the DDIC database view DEMO_SCARR_SPFLI.

Addition

... WITH PRIVILEGED ACCESS

Effect

The addition WITH PRIVILEGED ACCESS is currently ignored by DDIC database tables and DDIC views.

Notes

  • If CDS access control is implemented for DDIC database tables and DDIC views in a future release, the addition WITH PRIVILEGED ACCESS will turn it off.
  • If the addition WITH PRIVILEGED ACCESS is specified, the syntax check is performed in strict mode from Release .

Alternative 2

... cds_entity$[sql_para$]$[sql_path$]$|$[ WITH PRIVILEGED ACCESS$]


Additions

1. ... sql_path

2. ... WITH PRIVILEGED ACCESS

Effect

Specifies a non-abstract CDS entity cds_entity created with the CDS DDL in ABAP CDS. Possible CDS entities are:

The CDS entity cds_entity is specified using its name defined after the respective DEFINE statement of the CDS DDL.

  • If the CDS entity has input parameters, actual parameters must be assigned to them in a parenthesized list sql_para.

CDS table functions and CDS hierarchies are database extensions that are not supported by all database systems. The CDS DDL in ABAP CDS, however, enables CDS entities to be created and used as data sources regardless of the database system. In ABAP programs, CDS entities like this can also be specified as a data source of a SELECT statement regardless of the database system. The following applies here:

  • A catchable exception of the class CX_SY_SQL_UNSUPPORTED_FEATURE is raised if the statement detects that the current database system does not support the feature. The same applies when CDS entities are accessed that contain CDS table functions or CDS hierarchies as data sources.
  • When used, CDS entities like this produce syntax warnings from the extended program check, which can be hidden using the pragma
  • ##db_feature_mode[amdp_table_function]

CDS hierarchies are handled like SQL hierarchies and special rules apply.

Notes

  • In an ABAP program, it is possible to use the method USE_FEATURES of the class CL_ABAP_DBFEATURES to check whether the current database system or a database system accessed using a secondary connection supports CDS table functions or CDS hierarchies. This requires the constant AMDP_TABLE_FUNCTION or HIERARCHIES of the class to be passed to the method in an internal table.
  • If the name cds_entity is used to access CDS entities, the syntax check is performed in a strict mode from Release . Here, the statement is handled more strictly than in the regular syntax check. If CDS entities and DDIC database tables or DDIC views are both accessed in a SELECT statement, the syntax check is performed in astrict mode from Release .
  • If a CDS role is defined for the CDS entity and CDS access control is not disabled using the value #NOT_ALLOWED for the annotation @AccessControl.authorizationCheck or using the addition WITH PRIVILEGED ACCESS, CDS access control is applied to SELECT statements and only data that matches the access conditions is read. If no data is read due CDS access control, sy-subrc is set to 4 as usual. When a CDS-managed DDIC view is accessed, no implicit access control takes place.
  • By default, data aging is respected when an SAP HANA database is accessed, and only current data is read. This default setting can be changed using various methods.

Example

Reading of the data of the CDS view DEMO_CDS_SCARR_SPFLI.

Addition 1

... sql_path

Effect

Specifies a path expression sql_path after a CDS entity. In this case, the entity must be a CDS view entity, , or a CDS hierarchy that exposes the first CDS association of the path expression in its SELECT list or element list. A CDS view must be specified using its name cds_entity defined after DEFINE VIEW. All CDS associations of the path expression must be exposed in the SELECT lists of the CDS entities involved for use from outside.

The association target of the last CDS association of the path expression is the data source of the current SELECT statement. The data is read in accordance with the join conditions of the CDS associations and the other conditions of the CDS views involved.

The path expression exposes only the elements of its association target in the SELECT statement. If an element of this type is used as a column specified in other clauses of the SELECT statement and the column is assigned to the data source using the column selector ~, an alias name must be defined and used here using AS. Each path expression in the data source of the FROM clause must have an alias name defined with AS. This is checked in strict mode as of release.

Notes

  • A CDS entity cds_entity with a path expression can be used in join expressions, like any other data source.
  • In the SELECT statement, it is not possible to access elements of the entities of the path expression that are in front of the association target. This applies more specifically to the elements of the specified entity cds_entity. Regular access to these elements is possible only if they are specified again as data sources of explicit join expressions in the statement.
  • The obsolete addition CLIENT SPECIFIED cannot be used if a data source is specified using a path expression.
  • As the path expression is specified directly after cds_entity, source cannot and must not be specified here.

Example

Accesses the CDS view DEMO_CDS_ASSOC_SAIRPORT_TZ with parameter passing and a path expression with the CDS associations \_spfli and \_scarr in the FROM clause.

Path Expressions, Use in the FROM Clause

Addition 2

... WITH PRIVILEGED ACCESS

Effect

The addition WITH PRIVILEGED ACCESS disables CDS access control.

When a CDS entity is accessed to which a CDS role is assigned, its access conditions are not evaluated.

The addition WITH PRIVILEGED ACCESS cannot be specified together with a path expression sql_path. It affects only the CDS entity for which it is specified. It does not affect the CDS entities exposed using CDS associations of the specified CDS entity.

Notes

  • The addition WITH PRIVILEGED ACCESS overrides all delivered and self-defined roles.
  • CDS access control can also be disabled using the annotation @AccessControl.authorizationCheck:#NOT_ALLOWED when a non-abstract CDS entity is defined.
  • In updates, the addition WITH PRIVILEGED ACCESS must be specified when accessing all CDS entities for which CDS access control is not disabled using the annotation @AccessControl.authorizationCheck:#NOT_ALLOWED.
  • If the addition WITH PRIVILEGED ACCESS is specified, the syntax check is performed in strict mode from Release .

Example

Use of the addition WITH PRIVILEGED ACCESS when the CDS view DEMO_CDS_AUTHORITY_LITERAL is accessed, which is linked with the following CDS role:

Unlike the program DEMO_CDS_AUTH_LITERAL, the following read reads all data of the view.

Alternative 3

... +cte$[sql_path$]


Addition:

... sql_path

Effect

Specifies a common table expression cte in a subquery or the closing main query of a WITH statement.

The SELECT statement accesses the result set of the common table expression. All common table expressions can be used that were defined in the same WITH statement in front of the current SELECT statement.

Note

If a common table expression is used as the data source, a temporary database table is accessed, which is available during the WITH statement.

Example

Access to the result set of the common table expression +carriers in a join expression of the FROM clause of the main query of the statement WITH.

Addition

... sql_path

Effect

Specifies a path expression sql_path after a common table expression +cte that is specified as the data source of a query in a WITH statement. The common table expression must expose the first association of the path expression with the addition WITH ASSOCIATIONS. The association can be a CDS association or a CTE association.

The same rules apply as when specifying a path expression after a CDS entity cds_entity that is specified as a data source. In particular, the path expression must have an alias name defined with AS.

Example

The association target of the path expression \_scarr exposed by the common table expression +cte is used as the data source of the main query of a WITH statement.

Alternative 4

... hierarchy_data


Effect

Specifies the following hierarchy data:

Example

Access to an SQL hierarchy as a data source created by the hierarchy generator HIERARCHY.

Alternative 5

... @itab


Effect

Specifies an internal table @itab as a host variable whose name itab must be prefixed with the @ character. For more information, see SELECT - FROM @itab.

Example

Use of SELECT to access an internal table using as an alternative to the statement READ TABLE. Unlike READ TABLE, the statement SELECT offers a (dynamic) WHERE condition and evaluates the field list for the inline declaration. The statement is executed on the AS ABAP and the data in the internal table is not transported to the database.

Alternative 6

... cds_system_entity


A CDS system entity cds_system_entity is a a CDS entity provided by ABAP SQL that contains general functionality for generating tabular data.

The syntax for accessing a CDS system entity is the same as for any CDS entity described above.

Note

CDS system entities can also be accessed in other CDS entities.

Example

The following source code demonstrates the creation of a series of numbers using the CDS system table function SERIES_GENERATE_INTEGER.






BAL_S_LOG - Application Log: Log header data   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.

Length: 26538 Date: 20240425 Time: 121342     sap01-206 ( 321 ms )