HANA 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.
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.
At the moment, in AMDP Debugger
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.
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.