Can you please give me a clear explanation on the difference between using "standard table of", "Hashed table of", or simply "table of". Also what is the meaning of "initial size 0"?
For reference please have a look in to below code..
it_c01_d006_raw TYPE STANDARD TABLE OF /bic/ac01_d00600
INITIAL SIZE 0,
it_c01_d006 TYPE HASHED TABLE OF /bic/ac01_d00600
WITH UNIQUE KEY /bic/cemployee /bic/cdatetype,
it_c01_d002 TYPE TABLE OF /bic/ac01_d00200.
Sorted tables are appropriate for partially sequential processing in a LOOP, as long as the WHERE condition contains the beginning of the table key. Hashed Tables: Hashes tables have no internal linear index. You can only access hashed tables by specifying the key.
Hashed table. Table category of an internal table whose rows are stored internally in accordance with a hash algorithm and can be accessed using a unique hash key. A hashed table does not have a primary table index, but it can be assigned a secondary table index using a secondary table key.
standard table - ABAP Keyword Documentation. Table category of an internal table that is managed using a primary table index and which does not have a unique primary table key. When a standard table is accessed using its primary table key, it is searched linearly.
The key of a standard table is always non-unique, and you may not include any specification for the uniqueness in the table definition. the number of table entries. Sorted tables are always saved correctly sorted by key.
The meaning of TYPE STANDARD TABLE OF
and TYPE TABLE OF
is exactly the same, STANDARD
is implied if nothing else is specified. However, in the OO-context you are now expected to declare internal tables fully and you would not be able to leave out the STANDARD
addition. In this case it is just a stock-standard internal table that can be accessed by reading per the table index, or by key if you have sorted the table manually.
A table of TYPE HASHED TABLE
creates an internal table that is represented using an internal HASH algorithm, allowing reads to the table where the cost is (by approximation) independent from the size of the table. Using this type of table is good when you have large data-sets with a lot of reads, but comparatively few writes. When declaring a hash table you have to also declare a UNIQUE KEY
, as the HASH algorithm is dependent on this.
INITIAL SIZE 0
is also a redundant use of code - it means that memory allocation will occur in set blocks. (I'm not sure if this size is predefined, or configurable by BASIS), but INITIAL SIZE 0 is the default. If you wanted memory allocation to happen in sets of 10 times the number of lines in your internal table, you would have used 'INITIAL SIZE 10', but in most cases leaving the default memory allocation is better than trying to force it.
In addition
A table of TYPE SORTED TABLE
can be declared with either an UNIQUE
or a NON-UNIQUE
key. The cost to read a record is less than that of a STANDARD
table, as it allows a BINARY SEARCH
, but more than that of a HASHED
table. The cost to write is slightly more expensive than a STANDARD
table, but less than that of a HASHED
table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With