14.01.2020 Views

ABAP_to_the_Future

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

15

ABAP Programming for SAP HANA

the duration of the procedure. As such, later on in the stored procedure you can

do a SELECT upon that table, just like any other database table.

Even though you’re not supposed to use them, a few words on CE functions:

There are a fair few CE functions available in SQLScript, but only a subset of them

are currently usable in AMDPs. The one most often (in fact, usually the only one)

mentioned in the AMDP examples you’ll see on the Internet is CE_CONVERSION,

which is for when you have a database ta ble full of amounts in different currencies

and you want to unify them. Such an example can be seen in Listing 15.14.

lt_final_table =

ce_conversion( :lt_items_in_different_currencies,

[ family = 'currency',

method = 'ERP',

steps = 'shift,convert,shift_back',

source_unit_column = "CURRENCY_CODE" ,

output_unit_column = "CURRENCY_CODE_CONV",

target_unit = 'VND', “Vietnamese Dongs

reference_date = :ld_today,

client = :id_mandt ],

[total_field] ) ;

Listing 15.14 Calling a CE Function

As a final point, even though you’re not coding in ABAP inside an AMDP, the

syntax check will know that the langua ge inside the method is SQLScript and

adapt accordingly (i.e., you will get an error if you have syntax errors in your

SQLScript).

Summary

You’ve now defined an ABAP class that implements IF_AMDP_MARKER_HDB to allow

methods of that class to be executed inside the SAP HANA database and defined a

method for that purpose. Then, you created a method implementation with special

annotations so that the runtime system knows that this method should run in the database

as opposed to the application server. Finally, you coded the method—in

SQLScript, as opposed to ABAP—using asso rted features that duplicate the business

logic you would normally code inside your ABAP method to manipulate data that you

have retrieved from the database.

As the AMDP method runs in the database, all the business logic is run before the

results are returned to the calling program that runs in the application server. Thus, the

code—just as in the last section on CDS views—has been pushed down to the database.

676

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!