HANA SQL – Internal Table with Operations

light111HANA SQL Script – Internal Table with different operations


The post describes how to use HANA SQL Script to declare Internal table in AMDP and few operations like SEARCH, READ etc.

Here we have a simple class with one AMDP procedure. 

Initially one internal table is declared- LT_SCARR1

BY referring to this internal table LT_SCARR1 , another internal table LT_SCARR2 is declared.

12

RECORD_COUNT( ) – Operator is used to get to know the no of lines in the internal table. So it is likes LINES( ) / DESCRIBE table in ABAP.

It is not possible to direct assign a table to another table( basically non scalar assignment not possible). So One way we can use the WHILE Loop to read records from lT_SCARR1 and then fill it in LT_SCARR2. 

we have a report that calls the AMDP procedure and we can see the details in debugging.

3


At the moment, in AMDP Debugger

4


Now let’s see how to use SEARCH() and EXISTS() operator in HANA SQL Script in AMDP.

The SEARCH() can be applied on an internal table and it receives two arguments, the column name and the value, it it finds then it returns the index of that record within the internal table.

EXISTS() tells whether the record exists or not.

5

Debug Details-

6


If the SEARCH() is not successful, the returned index is 0. Slightly different than ABAP Read.

Here the search() applied two times, first time its success and second time its failed.

LV_POS = 10

7

LV_POS = 0

8


 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s