SAP Table Types I. Transparent Tables (BKPF, VBAK, VBAP, KNA1, COEP)
SAP Table Types I. Transparent Tables (BKPF, VBAK, VBAP, KNA1, COEP)
already buffered, then a select statement against it is very fast. To determine if a table
is buffered, choose the 'technical settings' soft button from the data dictionary display
of a table (SE12). Pool tables should all be buffered.
Table type
You can specify the table type <tabkind> as follows:
Line type
For the line type <linetype>, you can specify:
Any
data type if you are using the TYPE addition. This can be a predefined ABAP type, a local type in the
program, or a data type from the ABAP Dictionary. If you specify any of the generic elementary types C,
N, P, or X, any attributes that you fail to specify (field length, number of decimal places) are automatically
filled with the default values. You cannot specify any other generic types.
Anydata object recognized within the program at that point if you are using the LIKE addition. The line
type adopts the fully-specified data type of the data object to which you refer. Except for within classes,
you can still use the LIKE addition to refer to database tables and structures in the ABAP Dictionary (for
compatibility reasons).
All of the lines in the internal table have the fully-specified technical attributes of the
specified data type.
Key
You can specify the key <key> of an internal table as follows:
[UNIQUE|NON-UNIQUE] KEY <col1> ... <col n>
In tables with a structured line type, all of the components <coli> belong to the key as
long as they are not internal tables or references, and do not contain internal tables or
references. Key fields can be nested structures. The substructures are expanded component
by component when you access the table using the key. The system follows the sequence of
the key fields.
[UNIQUE|NON-UNIQUE] KEY TABLE LINE
If a table has an elementary line type (C, D, F, I, N, P, T, X), you can define the entire line
as the key. If you try this for a table whose line type is itself a table, a syntax error occurs. If
a table has a structured line type, it is possible to specify the entire line as the key. However,
you should remember that this is often not suitable.
[UNIQUE|NON-UNIQUE] DEFAULT KEY
This declares the fields of the default key as the key fields. If the table has a structured line
type, the default key contains all non-numeric columns of the internal table that are not and
do not contain references or internal tables. If the table has an elementary line type, the
default key is the entire line. The default key of an internal table whose line type is an
internal table, the default key is empty.
Specifying a key is optional. If you do not specify a key, the system defines a table type with
an arbitrary key. You can only use this to define the types of
field symbols and the interface parameters of procedures . For exceptions, refer to Special Features of
Standard Tables.
The optional additions UNIQUE or NON-UNIQUE determine whether the key is to be unique or
non-unique, that is, whether the table can accept duplicate entries. If you do not specify
UNIQUE or NON-UNIQUE for the key, the table type is generic in this respect. As such, it can
only be used for specifying types. When you specify the table type simultaneously, you must
note the following restrictions:
You cannot use the UNIQUE addition for standard tables. The system always
generates the NON-UNIQUE addition automatically.
You must always specify the UNIQUE option when you create a hashed table.
Examples
TYPES: BEGIN OF LINE,
COLUMN1 TYPE I,
COLUMN2 TYPE I,
COLUMN3 TYPE I,
END OF LINE.
TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.
The program defines a table type ITAB. It is a sorted table, with line type of the structure
LINE and a unique key of the component COLUMN1.
TYPES VECTOR TYPE HASHED TABLE OF I WITH UNIQUE KEY TABLE LINE.
TYPES: BEGIN OF LINE,
COLUMN1 TYPE I,
COLUMN2 TYPE I,
COLUMN3 TYPE I,
END OF LINE.
TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.
TYPES: BEGIN OF DEEPLINE,
FIELD TYPE C,
TABLE1 TYPE VECTOR,
TABLE2 TYPE ITAB,
END OF DEEPLINE.
TYPES DEEPTABLE TYPE STANDARD TABLE OF DEEPLINE
WITH DEFAULT KEY.
The program defines a table type VECTOR with type hashed table, the elementary line type I
and a unique key of the entire table line. The second table type is the same as in the
previous example. The structure DEEPLINE contains the internal table as a component. The
table type DEEPTABLE has the line type DEEPLINE. Therefore, the elements of this internal
table are themselves internal tables. The key is the default key - in this case the column
FIELD. The key is non-unique, since the table is a standard table.