The TYPES statement can be used to create a new local internal table in your program. The syntax is as follows.
[INITIAL SIZE <n>].
TYPE or LIKE can be used, the type constructor defines the table type <TABKIND>, the <linetype> and the <key> of the table. With the INITIAL SIZE the size of the table can be defined.
Table types can be as follows.
INDEXED TABLE
HASHED TABLE
STANDARD TABLE
SORTED TABLE
The minimum size of an internal table is 256 bytes.
ANY TABLE
Has GENERIC TYPES
INDEXED TABLE
Has GENERIC TYPES, INDEX ACCESS
HASHED TABLE
FULLY SPECIFIED TYPES, NO INDEX ACCESS, KEY ACCESS. Basically a HASHED TABLE does not have a linear Index and can be accessed by using its key. The response time is constant and does not depend on the number of records. While defining a HASHED TABLE the key that has been defined should be UNIQUE. This table is searched using a HASHED algorithm.
STANDARD TABLE (INDEXED TABLE)
FULLY SPECIFIED TYPES, INDEX ACCESS, KEY ACCESS. These tables have a linear INDEX. These tables can be accessed using the INDEX or the KEY. The response time here does depend on the number of records in the table. While defining the INDEX TABLE the KEY has always to be NON UNIQUE. UNIQUE key is not allowed.
SORTED TABLE (INDEXED TABLE)
FULLY SPECIFIED TYPES. INDEX ACCESS, KEY ACCESS. They have an internal INDEX and are always SORTED by the KEY while saving. While doing a KEY access the response time does depend on the number of records in the internal Table. Here the system uses a binary search. In sorted tables the KEY can be UNIQUE as well as NON UNIQUE
Examples of Defining Tables.
VBELN LIKE VBAK-VBELN,
KUNNR LIKE KNA1-KUNNR,
MATNR LIKE MARA-MATNR,
END OF SalesOrd.
STANDARD TABLE
SORTED TABLE
HASHED TABLE
Appending lines to an Internal Table.
Appending a Single Line
To add a line to an index table, use the statement:
Sorting Internal Tables.
Internal Tables are sorted as follows.
Attributes of an Internal Table.
You can use the following statement to find the attributes of an Internal Table at Runtime.
OCCURS will return the initial size of the table to the variable <n>.
KIND parameter, will return the table type to the variable <k>: ‘T’ for standard table, ‘S’ for sorted table, and ‘H’ for hashed table.
True or False
1) Hashed Tables can have UNIQUE key TRUE
2) SORTED Tables can have only NON UNIQUE KEY FALSE
3) STANDARD Tables can have UNIQUE as well as NON UNIQUE KEY FALSE
4) HASHED Tables Do not have an INDEX ACCESS TRUE
5) The Access time in a Hashed Table depends on the Number of records in the table FALSE
No comments:
Post a Comment