AS ABAP Release 753, ©Copyright 2019 SAP AG. All rights reserved.ABAP Keyword Documentation → ABAP − Reference → Processing External Data → ABAP Database Access → AMDP - ABAP Managed Database Procedures → AMDP - Methods →
METHOD - BY DATABASE PROCEDURE, FUNCTION
METHOD meth BY DATABASE PROCEDURE|FUNCTION
[USING SCHEMA schema1 OBJECTS db_entities]
[USING SCHEMA schema2 OBJECTS db_entities]
Implements an AMDP procedure or an AMDP function in an AMDP class. The addition BY DATABASE PROCEDURE or BY DATABASE FUNCTION can be specified in the implementation part of a global class that contains an appropriate tag interface IF_AMDP_MARKER_... for AMDP classes.
The parameter interface of the method declared in the declaration part must meet the prerequisites for AMDP procedure implementations or AMDP function implementations. The parameter interface of an AMDP function implementation that implements a CDS table function is taken from the definition of the CDS table function specified after the addition FOR TABLE FUNCTION in the declaration of the method.
The addition FOR db defines the database system where the method is used. The addition LANGUAGE defines the database-specific language in which the method is implemented. OPTIONS is used to specify database-specific options. USING is used to declare database objects managed by ABAP that are used in the AMDP method.
If the current AS ABAP does not have sufficient authorizations to manage database procedures or database functions in its database system, syntax errors can occur in AMDP methods. Missing authorizations can be detected using transaction SICK.
... FOR db
Determines the database system for which the AMDP method is used. The AMDP class must contain the appropriate tag interface. The following table shows the syntax that can be specified for db, the database system it identifies, and the required tag interface.
|db||Database System||Tag Interface|
|HDB||SAP HANA database||IF_AMDP_MARKER_HDB|
The AMDP method can only be called in an AS ABAP whose standard database is managed by the specified database system; otherwise a runtime error is produced.
... LANGUAGE db_lang
Determines the database-specific language in which the AMDP is implemented. The following table shows the syntax for db_lang used to specify the language (depending on the specified database system db), the meaning, and a link to further information.
|HDB||SQLSCRIPT||SQLScript||SQL Script for the SAP HANA Database|
|HDB||LLANG||L||L for the SAP HANA database (for internal SAP use only and only for AMDP procedure implementations)|
If possible, the ABAP syntax check examines the implementation of the method for the specified language.
This is possible only if the check takes place on an AS ABAP whose standard database is managed by the
specified database system. The check is performed with respect to the currently installed version of the database. No checks take place on an AS ABAP with a different database system.
... OPTIONS db_options
Specifies database-specific options for the AMDP procedure or function. The following tables shows the syntax for option as specified by the database system in question, db and the associated meaning.
|HDB||READ-ONLY||Only reads are permitted on the database tables in the database procedure or database function. Other AMDP methods can be called only if also flagged as READ-ONLY.|
|HDB||DETERMINISTIC||For AMDP scalar functions only. If a query calls an AMDP scalar function more than once with the same values for the input parameters and with the option DETERMINISTIC, the function is performed only once and the result is buffered for the duration of the query. In AMDP scalar functions like this, no functions are allowed that could return non-matching values in different calls. More information can be found under SAP Hana SQLScript Reference.|
|HDB||SUPPRESS SYNTAX ERRORS||For internal use at SAP only: If the AMDP procedure accesses database objects not managed by ABAP that do not exist at the time of the syntax check, only syntax warnings are raised and not syntax errors. If a required object is missing at runtime, a catchable exception is raised.|
The option READ-ONLY can also be specified with the addition AMDP OPTIONS in the declaration of an AMDP method. It applies when specified either in the implementation or in the declaration of the method, or both.
The syntax check examines the specified options at runtime.
The option SUPPRESS SYNTAX ERRORS is not applied to database objects managed by ABAP that are specified after USING.
... USING db_entities
Declares the database objects managed by ABAP accessed in the AMDP procedure or function. The following must be specified after USING:
These tables, views, and procedures are from the current ABAP database schema used in the procedure. These database objects are specified after USING and, when used in the procedure, must be specified directly and without specifying the database schema. An AMDP procedure or function is specified using the syntax class=>meth. Here, class is the name of its AMDP class and meth is the name of the AMDP procedure implementation or function implementation.
Each database object specified after USING must also be used in the procedure or function. Any database objects other than those above managed by ABAP cannot be specified after USING and the procedure or function cannot be used to access database objects not specified after USING, with the following exceptions:
With the exception of the namespace /1BCAMDP/, database objects from the current database schema can be accessed in a database procedure or database function managed by AMDP only if they are managed by ABAP and specified after USING.
... USING SCHEMA schema OBJECTS db_entities
Declares a logical database schema and the database objects it contains that are accessed by the AMDP procedure or function.
For schema, only logical database schemas that the current ABAP database schema can be mapped to can be specified. The addition USING SCHEMA must be specified for each logical database schema of this type that is used in the AMDP method in a macro $ABAP.schema. The way this addition works is determined by the physical database schema that is mapped to the logical database schema schema.
The addition USING SCHEMA must be specified after the addition USING and only one USING SCHEMA addition is allowed for a logical database schema schema.