SAP FROM ADBC TO AMDP ABEXA



Get Example source ABAP code based on a different SAP table
  


VX_EXA_ONLY

SAP HANA, from ADBC to AMDP
This example demonstrates how a task can be performed using HANA-specific language elements.

ABAP_SOURCE_CODE
DEMO CL_DEMO_ADBC_TO_AMDP

ABAP_DESCRIPTION
The task is to read all rows from the database table SFLIGHT whose key fields MANDT, CARRID, and CONNID occur in a predefined three-column internal table. To do this, the example class calls various methods of the class CL_DEMO_FROM_ADBC_TO_AMDP in whose instance constructor the internal table connection_tab is filled in accordance with user input.



Latest notes:

The examples of using HANA-specific language elements shown in the methods are syntax-only examples. The task presented here can be solved just as well using AB_SQL , which is why AB_SQL is the preferred method as specified in the programming guidelines.
ABAP_HINT_END

Reference Implementation Using AB_SQL
The method ASQL shows how the task can be solved in AB_SQL by simply using the addition FOR ALL ENTRIES . The result of the method is used as a reference for the HANA-specific implementations.
METH CL_DEMO_FROM_ADBC_TO_AMDP=>ASQL

Using Native SQL with ADBC
The method ADBC solves the task by using HANA-specific Native SQL statements that are passed to the SAP HANA database using ADBC. The table with the key values is evaluated after the addition exists in a subquery of a select statement. To do this, a temporary table DEMO_ADBC_CONNECTIONS is created on the database and filled with the content of the connection_tab using the statement insert . To access the result of the select statement, a standard table std_flights must be declared as a local internal table of the method, since the return value flights cannot be used for ADBC. The temporary table DEMO_ADBC_CONNECTIONS is removed again after SPFLI is read.
METH CL_DEMO_FROM_ADBC_TO_AMDP=>ADBC

Call of a Database Procedure Using a Database Procedure Proxy
The method CDBP solves the task by implementing the HANA-specific select statement in a database procedure that is called by specifying a database procedure proxy in the statement CALL DATABASE PROCEDURE . In a more realistic example, the database procedure DEMO_ADBC_GET_FLIGHTS and the database procedure proxy DEMO_ADBC_GET_FLIGHTS_PROXY would already exist and the implementation of the method would be restricted to the call CALL DATABASE PROCEDURE (see the executable example for procedure calls). In this example, the database procedure and the database procedure proxy are created temporarily and deleted again using ADBC methods and the associated API. The input parameter connections of the procedure references an additional temporary HANA table type, DEMO_ADBC_CONNECTIONS_TYPE . HANA does not support a separate type for numeric text, which means that the type NVARCHAR(4) must be used for the column CONNID . Therefore, the internal table connection_tab must be assigned to a temporary table connections with the correct row type before the procedure is called. No auxiliary table is required for the result, since the row type is described using an ABAP Dictionary type. An appropriate mapping can be performed for this type using the mapping table params. As an alternative to an auxiliary table for connection_tab, its data type could also be declared in the ABAP Dictionary and an appropriate mapping performed.
The statement CALL DATABASE PROCEDURE is not possible on a SAP HANA Cloud database.
METH CL_DEMO_FROM_ADBC_TO_AMDP=>CDBP

Call an AMDP Procedure
The method AMDP solves the task in the easiest possible way by calling an AMDP method AMDP_METH in which the HANA-specific select statement is implemented in an AMDP procedure. The main advantage of the AMDP method is that it can be called in the same way as any ABAP method and no auxiliary tables must be introduced, as was the case in the preceding examples.
METH CL_DEMO_FROM_ADBC_TO_AMDP=>AMDP

METH CL_DEMO_FROM_ADBC_TO_AMDP=>AMDP_METH