SAP ITAB ACCESS



Get Example source ABAP code based on a different SAP table
  



ABAP_ITAB - Accessing Internal Tables
When internal tables are accessed, either the entire table
BEGIN_SECTION VERSION 5 OUT or table body
END_SECTION VERSION 5 OUT , or individual lines can be addressed.
The entire table is accessed using special statements such as SORT, but also using general statements where internal tables can be specified at operand positions. Examples are assignments, parameter passing, target or source areas in AB_SQL and many other statements that return or expect tabular data.
Individual lines are accessed using the following:
Special statements such as READ TABLE, LOOP AT, or MODIFY
Table expressions itab[ ... ].
Mesh path expressions mesh_path When individual lines are accessed, either a work area is used into which the line content can be read or from which it can be modified, or a line is linked to a field symbol or a data reference variable and these are used to access the line directly.
The table category and the table keys are significant when internal tables are processed:
The primary table index can be used to access index tables, that is, standard tables and sorted tables. These tables always have a primary index.
Primary table keys can be used for optimized access to sorted tables and hashed tables.
A secondary table index can be used to access any tables with a sorted secondary table index.
The secondary table key can be used for optimized access to any tables with a secondary sorted key or hash key.



Latest notes:

Internal tables must be specified at operand positions for internal tables when the statement is executed. Only index tables can be specified at operand positions that include index access.
In processing statements for internal tables, the operands can be generically typed with TYPE data or TYPE any as long as no table index is accessed. For index accesses, an operand must be typed at least with TYPE index table.
In expressions as FOR expressions or table expressions, an internal table must be typed at least with TYPE any table.
If the line type of internal tables contains object reference variables as the components comp, the attributes attr of the object to which the reference points can be used as key values for reading, sorting, and modifying table lines. This is always possible for statements that address individual components of the table.
The content of the primary table key cannot be changed for any writes to individual lines of sorted tables and hashed tables. If writes are performed in write positions across the entire table line in these tables, for example, as a target field of assignments or as actual parameters for output parameters, an exception is always raised. It is not possible to access entire table lines using field symbols, data references or table expressions.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
In the following example, data is written to an internal table with AB_SQL , sorting takes place, and reads are demonstrated with the statement READ TABLE and a table expression.
ABEXA 01055
ABAP_EXAMPLE_END