Before Netweaver 7.4 we use READ TABLE syntax to read the internal table, but with new release of Netweaver 7.4 SAP has introduced table expressions to read the internal table with brand new syntax.
We can read the internal table data with three possible ways.You will learn how to use table expressions to read the internal table which is different from old syntax READ TABLE … .
1. Index read – We can read the internal table data using the table index
.Old Syntax
1 2 3 |
READ TABLE IT_MARA INTO DATA(WA_MARA) INDEX 1. |
.New Syntax
1 2 3 |
DATA(WA_MARA) = IT_MARA[ 1 ]. |
2. Read using a free key – We can read the internal table using the free key.
.Old Syntax
1 2 3 4 5 |
READ TABLE IT_BOOKINGS INTO WA_BOOKINGS WITH KEY CARRID = 'AA' CONNID = '17' CUSTTYPE = 'P'. |
.New Syntax
1 2 3 4 5 |
DATA(WA_BOOKINGS) = IT_BOOKINGS[ CARRID = 'AA' CONNID = '17' CUSTTYPE = 'P' ]. |
3. Read using a table key – We can read the internal table by specifying the table keys
.Old Syntax
1 2 3 4 |
READ TABLE IT_BOOKINGS INTO WA_BOOKINGS WITH TABLE KEY CARRID = 'AA' CONNID = '17'. |
. New Syntax
1 2 3 4 |
DATA(WA_BOOKINGS) = IT_BOOKINGS[ KEY keyid COMPONENTS CARRID = 'AA' CONNID = '17' ]. |