Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing External Data →  ABAP Database Accesses →  Native SQL →  AMDP - ABAP Managed Database Procedures 

METHOD - BY DATABASE PROCEDURE

Other versions: 7.31 | 7.40 | 7.54

Syntax


METHOD meth BY DATABASE PROCEDURE 
            FOR db
            LANGUAGE db_lang
            [OPTIONS db_options]
            [USING   db_entities].
  ...
ENDMETHOD.

Extras

1. ... FOR db
2. ... LANGUAGE db_lang
3. ... OPTIONS db_options

4. ... USING db_entities

Effect

Implements an AMDP method in an AMDP class. The addition BY DATABASE PROCEDURE can be specified in the implementation section of a global class that contains an appropriate tag interface IF_AMDP_MARKER_db. The parameter interface of the method declared in the declaration section must meet the prerequisites for AMDP methods.

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 can be used to declare database-specific options and USING can be used to declare the database objects managed by ABAP for use in the AMDP method.


Note

If the current AS ABAP does not have sufficient authorizations to manage database procedures in its database system, syntax errors can occur in AMDP methods. Missing authorizations can be detected using transaction SICK.

Examples

See AMDP - Examples.

Addition 1

... FOR db

Effect

Defines 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 central database is managed by the specified database system; otherwise a runtime error is produced.


Notes

  • An AMDP class can contain multiple tag interfaces for different database systems for implementing AMDP methods in various languages.
  • To define an AMDP class as global, it is recommended that a regular method is offered that calls AMDP methods as specified by the database system of the central database of the current AS ABAP. In database systems that do not support AMDP, a regular method can be created using an alternative implementation in Open SQL or Native SQL.

Addition 2

... LANGUAGE db_lang

Effect

Defines 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.

db db_lang Language More Information
HDB SQLSCRIPT SQLScript SQLScript for the SAP HANA database
HDB LLANG L L for the SAP HANA database (used internally at SAP only)

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 central 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.

Addition 3

... OPTIONS db_options

Effect

Specifies database-specific options for the AMDP procedure. The following tables shows the syntax for option as specified by the database system in question, db and the associated meaning.

db option Meaning
HDB READ-ONLY Only reads are permitted on the database tables in the database procedure.
HDB SUPPRESS SYNTAX ERRORS For internal use at SAP only: If database objects in the AMDP procedure are accessed, which do notexist at the time of the syntax check, then only syntax warnings are raised and not syntax errors. If a required object is missing at runtime, acatchable exception is raised.

The syntax check examines the specified options at runtime.


Note

The addition OPTIONS READ-ONLY must be specified in the implementation of L procedures.

Addition 4

... USING db_entities

Effect

Declares the database objects managed by ABAP accessed in the AMDP procedure. The following must be specified after USING:

  • All database tables and views from ABAP Dictionary
  • All procedures managed by AMDP

These tables, views, and procedures are from the current 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 is specified using the syntax class=>meth. Here, class is the name of its AMDP class and meth is the name of the AMDP method.

Each database object specified after USING must also be used in the procedure. Any database objects other than those above managed by ABAP cannot be specified after USING and the procedure cannot be used to access database objects not specified after USING, with the following exceptions:

  • Database objects in the current database schema if they are not in the namespace of the namespace prefix /1BCAMDP/. If used in the procedure, they must be specified directly and without specifying the database schema.
  • Database objects from a different database schema using their full qualified names.

With the exception of the namespace /1BCAMDP/, database objects from the current database schema can be accessed in a database procedure managed by AMDP only if they are managed by ABAP and specified after USING.


Notes

  • Explicit declarations of database objects used in the procedure are required for various static checks and enable, for example, the visibility of an AMDP method to be passed to the database level.
  • An object specified after USING must be visible here. An AMDP method from a different class can be specified only if it can be used by the current class and, accordingly, can only be called in the database procedure. This applies the visibility concept in ABAP Objects to the database system, even if it does not have a similar concept.
  • When an AMDP method class=>meth is specified after USING, the ABAP runtime environment identifies this as a use of the class class and its static constructor is executed before the first call of the AMDP method. This means that, if an AMDP procedure calls other AMDP procedures, the corresponding static constructor is executed.
  • AMDP methods in the same class must also be specified after USING, if used in the procedure.
  • The namespace /1BCAMDP/ is intended for temporary database tables, views, or database procedures of the current database schema accessed in AMDP procedures.
  • The addition USING cannot be specified in the implementation of L procedures.

Continue

AMDP - SQL Script for the SAP HANA Database

AMDP - L for the SAP HANA Database