97102 abap internal_tables


Published on


Published in: Education, Business, Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

97102 abap internal_tables

  1. 1. ABAP/4 Internal Tables• Internal Table – 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 • Defined using the occurs n – Header line holds current row being retrieved or added to the table. • Automatically created using begin of… • Using like will not create header line. • Nested internal table does not have header line
  2. 2. ABAP/4 Internal Tables1data: BEGIN OF itab1 OCCURS 10, f1, f2, f3, END OF itab1.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.
  3. 3. ABAP/4 Internal Tables• 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
  4. 4. ABAP/4 Internal Tables• 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.
  5. 5. ABAP/4 Internal Tables • Reading Data from an Internal Table: – LOOP AT • Reads multiple rows from an internal table into a work area.. f1 f2 1 A XX Itab 2 B YY 3 C YYLOOP AT itab. write: / sy-tabix, itab-f1, itab-f2.ENDLOOP.WRITE: / done. sy-tabix =, sy-tabix, / sy-subrc =, sy-subrc.OUTPUTS:7 A XX8 B YY9 C YYDone sy-tabix = 99 sy-subrc = 0
  6. 6. ABAP/4 Internal Tables• 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.