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

way.) Another restriction is that in a method that is to be implemented as an AMDP,

you cannot have returning parameters, and all parameters have to be passed as values.

The ABAP in Eclipse aspect of this is unlikely to ever change, but I wouldn’t be shocked

if the other restrictions were lifted at some point in the future. For example, before

ABAP 7.4 SP 8, you couldn’t have CHANGING parameters in a method that was going to

be implemented as an AMDP; now you can. In the same way, before SP 8, any sort of

exception caused a short dump; after SP 8, the exception can be caught by CATCH cx_

admp_error.

In a stored procedure, you have two choices when retrieving data from the database:

SQL statements or calculation engine (CE) functions. A year ago, SAP’s position

was that you should use CE functi ons whenever possible. Now, the instruction

is not to touch them with a 10-fo ot bargepole. CE functions were once

supposed to perform faster for basic operations, but over time the performance of

real SQL statements has improved to th e extent that the overhead of wrapping

them in a CE function is not worth it.

In any event, the important thing is to keep the two (SQL statements and CE functions)

apart. As an example, you may have encountered a dual-stack SAP Process

Integration (PI) system in which half of the code was in ABAP and half in Java.

The ABAP code ran fast, the Java code not quite so fast but okay, but the performance

killer was when data had to keep moving between the two stacks. In the

same way, if you have both SQL statemen ts and CE functions in one stored procedure,

then the poor old database is thrown into a tizzy, and the performance is

much worse than if you had used only one or the other.

An SQL statement in SQLScript does not look that radically different from its

ABAP equivalent; you just have lots more options available and the syntax (punctuation

marks) changes slightly. You saw this just now when we talked about CDS

views. The change here is that CDS views manage the client for you; in an AMDP,

you have to specify the client.

In Listing 15.13, you’ll see some SQLScript code to do a database SELECT from

within an AMDP method implementation.

METHOD get_people_scared_today BY DATABASE PROCEDURE

FOR HDB

LANGUAGE SQLScript

OPTIONS READ-ONLY

USING zt_monsters zt_scary_event_header zt_scary_event_items.

674

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

Saved successfully!

Ooh no, something went wrong!