Get Example source ABAP code based on a different SAP table
• WITH TYPES
TYPES>, tabkeys> Short Reference >
ABAP_SYNTAX ... $[ WITH key> $]> $[ WITH secondary_key1> $] $[ WITH secondary_key2> $] ...> $[ ${WITH$|WITHOUT$} FURTHER SECONDARY KEYS $] ...>
ABAP Addition 1 ... WITH FURTHER SECONDARY KEYS> 2 ... WITHOUT FURTHER SECONDARY KEYS>
What does it do? Definition of the table key of a table type. The following can be defined:
A primary table key> using key>>
Up to 15 secondary table keys> using secondary_key1>>, secondary_key2>>, ...> The order in which the components of a table key are defined is significant for the table type. The additions WITH$|WITHOUT FURTHER SECONDARY KEYS> determine the genericness with respect to the secondary table key. An internal table type that has no table key or an incomplete table key is generic with respect to the table key. Such a table type can only be used for typing> formal parameters or field symbols. A standard table type with a generic primary table key only can be specified for DATA>> after TYPE >. This creates a bound table type with a standard key>. Primary Key> The genericity of a table type with respect to the primary key is determined as follows:
If WITH key>> is not specified, a table type is fully generic with respect to the primary key.
If there is no declaration about the uniqueness of the key in key>>, a table type is partly generic with respect to the key.
If a key declaration with a uniqueness declaration is made in key>>, a table type is not generic with respect to the primary key. The non-generic table categories can be split up as follows:
If no primary key is declared for standard tables, this primary key is generic with respect to the key fields and defined implicitly as non-unique.
If no primary key is declared for sorted tables, this primary key is generic with respect to the key fields and uniqueness.
If no primary key is declared for hashed tables, this primary key is generic with respect to the key fields and uniqueness. However, it is important to note that concrete hashed tables can have only one unique key. Secondary Key> The genericity of a table type with respect to the secondary keys depends on that of the primary key by default and can be overridden using the additions WITH$|WITHOUT FURTHER SECONDARY KEYS >.
If the primary key is completely or partially generic, the table type is by default generic with respect to the secondary keys. The default behavior can be expressed using the addition WITH FURTHER SECONDARY KEYS>. However, if the addition WITHOUT FURTHER SECONDARY KEYS> is specified, the table type is generic with respect to the primary key but not with respect to the secondary key.
If the primary key is not generic, then the table type is by default not generic with respect to the secondary key either. The default behavior can be expressed using the addition WITHOUT FURTHER SECONDARY KEYS >. However, if the addition WITH FURTHER SECONDARY KEYS > is specified, the table type is generic with respect to the secondary key but not with respect to the primary key.
Latest notes: A generic table type must not be used as a component of a structured type>. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 Definition of a table type for a hashed table> with a unique primary key as well as two non-unique secondary sorted keys>, cityfrom_to> and airp_from_to>. ABEXA 00725 ABAP_EXAMPLE_END • WITH FURTHER SECONDARY KEYS TYPES
ABAP Addition
What does it do? This addition explicitly specifies that the table type is generic with respect to the secondary key. This means that it includes table types that can have further secondary keys in addition to the optional secondary keys specified using WITH secondary_key> ...>. If 15 secondary keys are already defined, the addition WITH FURTHER SECONDARY KEYS> cannot be specified.
Latest notes:
This addition expresses the default behavior in table types with a generic primary key.
In table types with a non-generic primary key, WITH FURTHER SECONDARY KEYS> can be used to override the default behavior and make it generic with respect to the secondary keys. NON_V5_HINTS ABAP_HINT_END • WITHOUT FURTHER SECONDARY KEYS TYPES
ABAP Addition
What does it do? This addition explicitly specifies that the table type is not generic with respect to the secondary key. This means that it includes only table types that have exactly those secondary keys specified using WITH secondary_key> ...>.
Latest notes: This addition expresses the default behavior in table types with a generic primary key. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The addition WITH FURTHER SECONDARY KEYS> in the declaration of the tabular type itab> enables the passing of internal tables with any secondary keys to the parameter p> of the method meth >. Without this addition, the addition WITHOUT FURTHER SECONDARY KEYS> would be used implicitly and the method call shown would not be possible. ABEXA 00726 ABAP_EXAMPLE_END