You use the DATA statement as well for tables as for fields. We use Structured Data Objects (structures) in Database Tables & Internal Tables. Data can be copied between structures, even if they are not the same type. Key factors when making an internal table: what fields to use, memory usage (only create the internal table with the components needed). Organisational structure factors: sort order, logical structure, key fields, uniqueness Whether fields need to be unique determines whether to use standard, sorted or hashed internal tables. Also affects performance of program.
Process for creating Internal Tables:
There are 3 types of Internal Tables:
STANDARD Internal Tables:
SORTED Internal Tables:
HASHED Internal Tables:
*Internal Table with Header line
DATA: BEGIN OF itab01 OCCURS 0,
surname LIKE zemployees-surname,
dob LIKE zemployees-dob,
END OF itab01.
*New Way of defining Internal Tables
*Declare a Line Type
TYPES: BEGIN OF line01_typ,
surname LIKE zemployees-surname,
dob LIKE zemployees-dob,
END OF line01_typ.
*Declare the 'Table Type' based on the Line Type / Structure.
TYPES itab02_typ TYPE STANDARD TABLE OF line01_typ (structure) [WITH NON-UNIQUE KEY List_of_fields].
*TYPES itab03_typ TYPE SORTED TABLE OF line01_typ
* WITH [UNIQUE | NON-UNIQUE] KEY surname dob.
*TYPES itab04_typ TYPE HASHED TABLE OF line01_typ
* WITH UNIQUE KEY List_of_fields.
*Declare/instantiate/create the table based on the 'Table Type'
DATA itab02 TYPE itab02_typ.
*Declare/instantiate/create the Work Area to use with our Internal Table
DATA wa_itab02 TYPE line01_typ.