HANA SQL: Internal Table with More Operations

light111HANA SQL: Internal Table with More Operations

In AS ABAP, we can use a row and an internal table and then we can append/insert row to the internal table.

But in HANA SQL we can not make this. Instead we can use two internal table and by using UNION operation we can fill the internal table.

In below we have two ITables (Internal Table)and in loop , lets fill an ITable and then at end of loop , push the result to the result ITable.


Test the AMDP Procedure with report.


Debug Details-1


Debug Details-2


Now let’s make use of FOR Loop and fill data from one table to another table.

The for loop  increments/decrements the LV_INDX and then it is checked against the boundary condition and FOR loop body is processed if the condition is successful.




Debug details-1


Debug details-1- the result table details.


 In usual case the the loop runs from 1 to no of records of the table, so 

LV_INDX -> 1,  then 2,  then 3, then 4, then 5, ….

But with addition of REVERSE into the FOR Loop it works in the opposite way.

LV_INDX -> ……. 5, then 4, then 3, then 2, then 1.

Lets look at this below- 


Debug Details- We are just entered the For Loop and the value of LV_INDX = 18 and then it decreases.


Debug details-


In FOR LOOP, it doesn’t make sense to initialize LV_INDX . The FOR Loop automatically assigns increments/decrements it.


Instead of adding a dynamic boundary to the FOR Loop , a static boundary condition can be applied. like –  1..10


Use of CONTINUE and BREAK in FOR Loop , it works same way as in ABAP.


The function IS_EMPTY( ) can be used and we can pass the Internal table name as an argument to it and then it checks the emptiness of the table , it is similar to IS INITIAL  check in ABAP.



One comment

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 )

Facebook photo

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

Connecting to %s