Get Example source ABAP code based on a different SAP table
ABAP_AMDP - SQLScript for the SAP HANA Database SQLScript> is a script language, documented in the SAP HANA SQLScript Reference> , and used to program SQLScript procedures> and SQLScript functions> in the SAP HANA database>. It is the implementation language of an AMDP method> that specifies the addition FOR HDB LANGUAGE SQLSCRIPT>> in the statement METHOD>. ITOC
Latest notes:
AS ABAP requires the following authorizations as a user of the database system to be able to manage SQLScript procedures and functions on the SAP HANA database:
Privilege Execute> on the object GET_PROCEDURE_OBJECTS> of the schema SYS>
Privilege Execute> on the object TRUNCATE_PROCEDURE_OBJECTS> of the schema SYS> Further authorizations are required for debugging AMDP methods in the ABAP Development Tools (ADT)>. Missing authorizations can be identified using transaction SICK>>. NON_V5_HINTS
SQLScript implementations in AMDP methods replace calls of database procedures using database procedure proxies> and the statement CALL DATABASE PROCEDURE>>. Database procedures can either be implemented completely in an AMDP method or an existing database procedure can be called from an AMDP method. In this case, the AMDP method replaces the database procedure proxy. Database procedure proxies are still recommended for scenarios in which secondary connections> are used to access existing procedures in SAP HANA database alongside the current standard AS ABAP database>. ABAP_HINT_END
AMDP Procedures and Functions in SAP HANA The SQLScript implementation of an AMDP method with the name meth> that belongs to an AMDP class class> is stored by the ABAP runtime framework as an SQLScript procedure under the name CLASS=>METH> in the ABAP database schema> of the SAP HANA database. The names must be written in uppercase letters when used in the database system. AS ABAP is responsible for all transports, administration, and access control. SQLScript procedures and functions managed using AMDP can be accessed as follows:
Calls from ABAP
Call of an AMDP procedure> or AMDP scalar function> with standard method call meth( ... ) >> in ABAP programs. For meth>, the associated AMDP procedure implementation> is specified.
Calls an AMDP table function> by specifying the assigned CDS table function> or a CDS view> that uses a CDS table function in an AB-SQL read statement.
Calls from other AMDP procedures or functions
An AMDP procedure or function implemented using SQLScript in the same class or a different class can call another AMDP procedure with the usual SQLScript syntax>:
CALL 'CLASS=>METH'( f1 => a1, f2 => a2, ... );>
The called AMDP procedure implementation CLASS=>METH> must be specified after the addition USING>> of the calling method. The usual visibility rules from ABAP Objects apply. A database procedure or database function implemented in a class cannot call a procedure implemented in a private AMDP procedure implementation of a different class, unless a friendship exists between the classes.
An AMDP procedure or function implemented using SQLScript in the same class or a different class can call another AMDP function implemented with SQLScript using the usual SQLScript syntax>:
SELECT ... FROM 'CLASS=>METH'( f1 => a1, f2 => a2, ... );>
The specified AMDP function implementation CLASS=>METH> must be specified after the addition USING>> of the calling method. An AMDP function implementation is always public. BEGIN_SECTION VERSION 5 OUT
Calls from regular database procedures An SQLScript procedure or function created in the regular way in SAP Web IDE for SAP HANA> or using Native SQL can call an SQLScript procedure or function implemented in an AMDP method or access an SQLScript function, as long as the procedure or function exists in the database system. This is not recommended>, however, since the AMDP procedures and functions are managed in AS ABAP and consistency can only be guaranteed for other AMDP procedures and functions from the same AS ABAP.
Access in SAP Web IDE for SAP HANA> Once the ABAP runtime framework has created an SQLScript procedure or function managed by AMDP in the database system, it is visible in SAP Web IDE for SAP HANA> and can even be edited. This is not recommended since this kind of change has no effect on the implementation in the AMDP method and can be overwritten by the ABAP runtime framework at any time. END_SECTION VERSION 5 OUT
ABAP_SYNTAX The syntax of a SQLScript procedure > or function> written in SQLScript is exactly as described under SAP Hana SQLScript Reference>, with one exception: The character * > at the start of a line indicates a comment>, as in ABAP. When the procedure or function is saved in the database system, the asterisk, *>, is transformed to the usual double hyphens, -->. BEGIN_SECTION VERSION 5 OUT All SQLScript operators CE_...> that support views can be used. SQLScript operators that do not support views, for example, CE_COLUMN_TABLE>, which only works with the technical property Column Store>, cannot be used. In an SQLScript procedure, the function SESSION_CONTEXT> is used for read access to the session variables> in the SAP HANA database. When called from ABAP, the ABAP-specific session variables> are set to the values of the corresponding ABAP system fields. When accessing a CDS table function> implemented in an AMDP table function > via AB_SQL , the session variable CDS_CLIENT> is set to the value specified in the optional addition USING CLIENT>>. However, write access to session variables with the SQLScript statement SET> is not allowed in an SQLScript procedure or function. END_SECTION VERSION 5 OUT