SAP CL ABAP DBFEATURES



Get Example source ABAP code based on a different SAP table
  


VERSION 5 OUT
• CL_ABAP_DBFEATURES ABAP_CLASS

CL_ABAP_DBFEATURES, Database Features
The method USE_FEATURES of the class CL_ABAP_DBFEATURES can be used to determine whether the current database or a database specified using a database connection supports particular features and whether these can be used at runtime in ABAP. One or more features can be queried by passing them to the method in an internal table. The possible line content of the internal table is determined by constants of the class CL_ABAP_DBFEATURES. Other values raise an exception of the class CX_ABAP_INVALID_PARAM_VALUE . The following tables list these constants, the respective database features and how they can be used in ABAP.

Use in AB_SQL ConstantDatabase FeatureUse in ABAP
AMDP_TABLE_FUNCTIONTable FunctionsAccess to CDS table functions in AB_SQL .
CTE_IN_CORRELATED_SUBQUERIES Common table expressions (CTE) Access to common table expression in correlated subqueries in AB_SQL .
EXTERNAL_VIEWSSAP HANA views Access to DDIC external views in AB_SQL .
GROUPING_SETSGrouping setsUse of grouping sets in the GROUP BY clause in AB_SQL .
HIERARCHIESHierarchy DataUse of hierarchy data as a data source of queries in AB_SQL .
INDICATORSNull indicator Use of addition INDICATORS in a SELECT statement in AB_SQL .
ITABS_IN_FROM_CLAUSELocal temporary tablesUse of internal tables as a data source of queries in AB_SQL , if these are evaluated by the database.
LIMIT_IN_SUBSELECT_OR_CTESorts or delimiters in subqueriesUse of the ORDER BY clause or the additions UP TO and OFFSET in subqueries in AB_SQL .
MODIFY_FROM_SELECTSubquery in UPSERTUse of a subquery as a data source of the statement MODIFY in AB_SQL .
ORDER_BY_NULLS_FIRST_LASTAddition to the ORDER BY clause Sort a result set after ORDER BY by determining the positions of potential null values in AB_SQL .
WINDOWINGWindow expressions Use of window expressions in a SELECT list in AB_SQL .
Caution
Up to now, many features have been introduced in and are supported by AB_SQL that work on SAP HANA only. Most of these features are not governed by CL_ABAP_DBFEATURES any more. Note that there is no syntax warning any more if such HANA-only features are used. Exceptions are raised if a statement using such features is sent to a non-HANA database using secondary connections.

Use in the ABAP Dictionary ConstantDatabase FeatureUse in ABAP
TABLE_KEYCNT_MAX1Up to 120 key fieldsA table can contain more key fields than is allowed as a platform-independent table.
TABLE_KEYLEN_MAX1Keys can have up to 2000 bytesThe key of a table can contain more bytes than is allowed as a platform-independent table.
TABLE_LEN_MAX1A table line can have up to 16293 bytesA table line can contain more bytes than is allowed as a platform-independent table.

Use in ABAP Calls ConstantDatabase FeatureUse in ABAP
CALL_AMDP_METHODSupports AMDP Method call of AMDP procedure implementations.
CALL_DATABASE_PROCEDURE Database ProceduresCall of database procedures using CALL DATABASE PROCEDURE.
The method USE_FEATURES returns the value of abap_true if the feature is supported by the database and the specified use in ABAP is possible.
Most of these features can be used statically in ABAP programs regardless of the current database system. This means there is no syntax error when one of these database features is used in an ABAP program. For example, it is possible to access DDIC external views in every ABAP program or AMDP methods can be called. An exception is raised only if the current database does not support the corresponding feature at runtime. A syntax warning from the extended program check that can be hidden by a pragma indicates the potential exception. The class CL_ABAP_DBFEATURES can be used to check whether a special form of access is possible at runtime, instead of catching the corresponding exception. Replacement implementations can be used if an access type is not possible.
The features TABLE_KEYCNT_MAX1, TABLE_KEYLEN_MAX1, and TABLE_LEN_MAX1 can currently only be used by SAP developers as internal flags for database tables, which indicate the tables potentially exceed globally defined and platform-independent sizes. When a table like this is accessed using AB_SQL , a syntax check warning from the extended program check is raised. This warning can be hidden by a pragma. The warning for TABLE_LEN_MAX1 is also raised for views that use a table of this type. In standard SAP systems, these tables are usually delivered within the general limits, but customers and partners can enhance them beyond these sizes. Tables enhanced like this can only be accessed on database systems that support these expanded limits. Other database systems use a replacement implementation that can be accessed using the class CL_ABAP_DBFEATURES.



Latest notes:

If a syntax warning from the extended program check due to enhanced database features is raised when a database object is accessed, it can be hidden by a pragma as long as the object was accessed on database systems that support the features or if there is a replacement implementation. If there is no guarantee that the object is accessed only on database systems that support the features, it is best to wrap the access behind an API.
Tables flagged as potentially exceeding platform-independent sizes should never be accessed globally. They should always be accessed within an API wrapper and the associated replacement implementation should be wrapped too.
As soon as all database systems support a database feature and it can be used in ABAP, the checks are no longer necessary. The associated constant is then disallowed and removed from the class CL_ABAP_DBFEATURES.
The class CL_ABAP_DBFEATURES_AUNITHELPER can be used to reduce the set of database features in CL_ABAP_DBFEATURES during a unit test. In programs that use CL_ABAP_DBFEATURES, this makes it possible to test replacement implementations for databases that support fewer features than the current database.
ABAP_HINT_END



Example ABAP Coding

For the current database, checks whether specific additional features can be accessed using AB_SQL .
ABEXA 00864
ABAP_EXAMPLE_END



Example ABAP Coding

The program DEMO_DBFEATURES checks all possible database features for the current database.
ABAP_EXAMPLE_END