1. TYPES
itabtype
{TYPE tabkind OF linetype|
LIKE
tabkind OF lineobj}
[WITH [UNIQUE|NON-UNIQUE] keydef]
[INITIAL SIZE n].
2. TYPES
itabtype {TYPE RANGE OF type| TYPES itabtype LIKE RANGE
OF f}.
3. TYPES itabtype {TYPE linetype|LIKE lineobj} OCCURS n.
The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See New
naming convention and LIKE reference for ABAP Dictionary types not allowed.
Defines a user-defined type (ABAP type concept) for an internal table.
TYPES itabtype {TYPE tabkind OF linetype|
LIKE
tabkind OF lineobj}
[WITH [UNIQUE|NON-UNIQUE] keydef] [INITIAL SIZE n].
Defines the type itabtype for an internal table without
header line in a program with table
type
tabkind and line type linetype
(if you use a TYPE reference) or the type of the referred
object
lineobj (if you use a LIKE
reference). Internal tables without a header line consist of any number of table lines, each of which
has the structure defined by the line type.
You may also define a table
key. If you do not, the system creates a generic table type
with any key. You can use generic types to specify the type of generic
subroutine parameters.
The UNIQUE and NON-UNIQUE
additions allow you to specify whether a table with type itabtype may contain two or more records with the same key or not. The following rules apply:
The optional INITIAL SIZE addition allows you to specify
how much memory should be allocated to the table when you create it. This corresponds to the
OCCURS specification in variant 2 (see also Performance
Notes for Internal Tables). The value n is not taken into consideration in the type check.
The following type definitions define tables using the line type STRUC and the key NAME:
TYPES: BEGIN OF STRUC,
NAME(10) TYPE C,
AGE TYPE I,
END
OF STRUC.
TYPES: TAB1 TYPE STANDARD TABLE OF STRUC WITH DEFAULT KEY,
TAB2 TYPE SORTED TABLE OF STRUC
WITH
NON-UNIQUE KEY NAME,
TAB3 TYPE HASHED TABLE OF STRUC WITH UNIQUE KEY NAME.
Unlike the above types, the following types are generic. This means that you can use them to specify
the type of a generic subroutine parameter, but not to create a table object uisng the
DATA statement. The only exception to this is that the system
allows you to use a generic standard table type in a DATA
statement - the type description is completed automatically by the system according to the rules described under DATA.
TYPES: GEN_TAB1 TYPE STANDARD TABLE OF STRUC,
GEN_TAB2 TYPE
SORTED TABLE OF STRUC WITH KEY NAME,
GEN_TAB3 TYPE HASHED TABLE OF STRUC.
The following example shows the definition of a sorted table using a LIKE
reference to the ABAP Dictionary structure SFLIGHT:
TYPES: FLTAB LIKE SORTED TABLE OF SFLIGHT
WITH NON-UNIQUE KEY CARRID CONNID FLDATE.
TYPES itabtype {TYPE RANGE OF type| TYPES
itabtype LIKE RANGE OF f}.
Creates a table type itab with table type STANDARD. The line type is a structure, made up as follows:
SIGN(1) TYPE C
OPTION(2) TYPE C
LOW
TYPE type or LIKE f
HIGH TYPE type or LIKE f
The table has the same structure as a RANGES
table and can be used in the same way. Tables defined using TYPE|LIKE
RANGE OF
have no headers, in contrast to tables defined using RANGES.
You can declare a suitable work area by including a TYPE|LIKE LINE
OF itab addition in a TYPES or DATA statement.
...INITIAL SIZE n
INITIAL SIZE specifies how many lines of the table are
created along with the table. The table size increases dynamically as required - for further information,
refer to
Performance Notes for Internal Tables. The INITIAL SIZE
value has no semantic meaning except in the APPEND
SORTED BY statement. If you do not specify an INITIAL SIZE, the system uses 0 as the default value.
TYPES itabtype {TYPE linetype|LIKE lineobj} OCCURS n.
This variant is not allowed in an ABAP Objects context. See Declaration with OCCURS not allowed.
Defines the type itabtype as the type for a standard table
without a header line. The key is the default key for internal tables.
This variant is the same as the following type definition:
TYPES itabtype {TYPE STANDARD TABLE OF linetype|
LIKE
STANDARD TABLE OF lineobj}
WITH DEFAULT KEY INITIAL SIZE n.
Type names
A type name can be up to 30 characters long. The name may only consist of alphanumeric characters and
the underscore character. It may not consist entirely of digits. Special characters such as German umlauts
are not allowed. As well as these characters, certain special characters are used internall.
However, these should not be used in application programs. SPACE
is a reserved name, and cannot therefore be used. Furthermore, you should not use a field in a statement
if it has the same name as one of the additions of the keyword (for example: PERFORM SUB USING CHANGING.).
Recommendations for Type Names:
Internal Table Types