‎2008 Feb 14 12:38 AM
Hi Guys,
I have an internal table with employee name and its attributes, like address, family etc. Each employee can have multiple records in the table.
I want to create a table of tables with key as employee ID and rest of the employee attributes inside the table.
So each employee then will have one row in the main table and all its attributes will be in the inner table.
Can someone please share a sample code to achieve this?
Regards,
~Mark
‎2008 Feb 14 5:13 AM
Hi,
Hashed tables
This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index. The response time for key access remains
constant, regardless of the number of table entries. Like database tables, hashed tables always have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for processing large amounts of data.
Example:
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.
Regards,
Bhaskar