12. Data structures and internal tables Flashcards
Structures
Temporary objects in program memory. Structures are used in connection with sequential datasets and subroutines as well as a “staging area” for internal tables.
Internal Tables
Internal tables are comprised of records which have the same format as an individual structure.
Internal tables are tables which only exist during the execution of a program.
Unlike the ABAP Dictionary transparent tables, internal table data is not stored on the database server. Internal table data resides in a program specific work area.
BEGIN OF / END OF
The start and end of the structure are indicated by BEGIN OF and END OF .
Types of internal tables
Standard, Sorted and Hashed
APPEND
APPEND statement uses the work area to append the line/row information into the table.
SY-TABIX statement
Row number in the table index of an internarl table. Contains the last row accessed using a primary or secondary table index. Is set to 0 when accessed using a hash algorithm.
When an internal table is read, the system field SY-TABIX is set to the index value of the internal table line which has been placed either in the header line or the work area
COLLECT
When the COLLECT statement is used, ABAP scans the internal table for entries which correspond to the header line in fields which are not of type P, I or F . E
SORT Statement
An internal table is sorted using the SORT statement. If sort criteria is not specified, the table is sorted by all fields (except those of data types P, I, and F) in ascending order in the sequence in which they were declared.
An internal table type is defined
using the TYPES statement. No memory is allocated when defining a type.
An internal table object is created with
the DATA statement by referring to an internal table type using the TYPE parameter. It is this DATA statement occupies memory. Internal table objects can also be created through a reference to an existing table or structure using the LIKE parameter.
implicit key
By default, all the records that you append to your internal table have a key. This key is the combination of all non-numeric fields. This is the implicit key.
Control Level Processing
When processing an internal table with the LOOP statement, it is possible to add additional code that will only be processed when a field changes.
READ TABLE
reads a single table entry.
READ TABLE WITH KEY ‘‘.
- Enter the search argument after the parameter KEY (in single quotes).
- Beginning with the first character of the first field of the first entry in the table, ABAP compares each record character by character with the search argument (‘‘).
READ TABLE WITH KEY ‘‘ BINARY SEARCH.
• Like variant 2, but using a binary search (faster than linear search).
• The internal table must be sorted in ascending order by the
search argument.