What is Internal Tables in SAP ABAP Programming
– Temporary table stored in RAM on application server (not on GUI)
– Created & filled during execution of program
– Consists of one or more rows with identical structure.
– Identical to a field string declaration
Consist of a body & optional header line.
– Body holds the rows of data
– Header line holds current row being retrieved or added to the table.
1 data: BEGIN OF itab1 OCCURS 10,
data itab2 LIKE ztxlfa1 OCCURS 100.
data itab3 LIKE ztxlfa1 OCCURS 100 with header line.
• BEGIN OF creates header
• LIKE does not create a header line
• LIKE add WITH HEADER LINE creates a header line.
• Defined using the occurs n
• Automatically created using begin of…
• Using like will not create header line.
• Nested internal table does not have header line
END OF itab1.
Adding data to an Internal Table
– APPEND [wa TO] itab.
• Wa must have same structure as row of body (Explicit work area)
• After APPEND sy-tabix is set to the relative row number of row just appended.
– APPEND itab to itab is identical to
– APPEND itab. (Default header line –implicit work area)
– APPEND INITIAL LINE TO itab
• Appends a row containing initial values (blanks & zeros)
• Same as CLEAR ITAB
• APPEND ITAB
Using the OCCURS addition:
– OCCURS 10 does not limit the number of rows.
– The system uses the OCCURS clause as a guideline to determine how much memory to allocate.
– More is allocated if needed.
– By default use OCCURS 0 – The system then allocates 8 KB of memory at run time.
Reading Data from an Internal Table:
– LOOP AT
• Reads multiple rows from an internal table into a work area..
LOOP AT itab.
write: / sy-tabix, itab-f1, itab-f2.
WRITE: / 'done. sy-tabix =', sy-tabix, / ' sy-subrc =', sy-subrc.
1 A XX
2 B YY
3 C YY
Done sy-tabix = 99
sy-subrc = 0
Restricting rows read from an internal table.
– Using FROM, TO and WHERE
• WHERE returns a subset but always performs a full table scan!.
– LOOP AT itab WHERE f2= ‘YY’
– LOOP AT itab from 2 to 3.
Use EXIT, CONTINUE or CHECK to control LOOP AT.Download attached file:
You must be Loged in to download file