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.

12

Test the AMDP Procedure with report.

3

Debug Details-1

4

Debug Details-2

5


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.

6

Test-

7

Debug details-1

8

Debug details-1- the result table details.

9


 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- 

10

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

11

Debug details-

12


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

13


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

14


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

15


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.

16


 

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 )

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