You are on page 1of 3

Table types

Table types are construction blueprints for internal tables that are stored in the ABAP Dictionary. When you create a table type in the ABAP Dictionary, you specify the line type, access type, and key. The line type can be any data type from the ABAP Dictionary, that is, a data element, a structure, a table type, or the type of a database table. You can also enter a predefined Dictionary type directly as the line type, in the same way that you can with a domain. In an ABAP program, you can use the TYPE addition to refer directly to a table type. If you define a local data type in a program by referring to a table type as follows: TYPES dtype TYPE table. The construction blueprint of the table type is used to create a local internal table dtype in the program. The predefined Dictionary data types of the domains used by the data elements in the structure are converted into the corresponding ABAP types. The semantic attributes of the data elements are used for the corresponding components of the internal table in the program.

Type Groups
Type groups were based on the include technique, and allowed you to store any type definitions globally in the Dictionary by defining them using TYPES statements. The definition of a type group is a fragment of ABAP code which you enter in the ABAP Editor. The first statement for the type group pool is always: TYPE-POOL pool. After that, you define data types using the statement TYPES. It was also possible to define global constants using the CONSTANTS statement. All the names of these data types and constants must begin with the name of the type group and an underscore: pool_ In an ABAP program, you must declare a type group as follows before you can use it: TYPEPOOLS pool. This statement allows you to use all the data types and constants defined in the type group pool in your program. You can use several type groups in the same program. Let the type group HKTST be created as follows in the ABAP Dictionary: TYPE-POOL hktst. TYPES: BEGIN OF hktst_typ1, col1(10) TYPE c, col2 TYPE i, END OF hktst_typ1. TYPES hktst_typ2 TYPE p DECIMALS 2.

CONSTANTS hktst_eleven TYPE i VALUE 11. This type group defines two data types HKTST_TYP1 and HKTST_TYP2, as well as a constant HKTST_ELEVEN with the value 11. Any ABAP program can use this definition with the TYPE-POOLS statement: TYPE-POOLS hktst. DATA: dat1 TYPE hktst_typ1, dat2 TYPE hktst_typ2 VALUE '1.23'. WRITE: dat2, / hktst_eleven. The output is: 1.23, 11

The data types defined in the type group are used to declare data objects with the DATAstatement and the value of the constant is, as the output shows, known in the program Example for type Group
*&---------------------------------------------------------------------* *& Report ZBASU_TYPE_GROUP * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT ZBASU_TYPE_GROUP TYPE-POOLs: ZTYPE . tables: mara. .

data: itab type table of ztype_basu with header line. select-options: material for mara-matnr. select * from mara into corresponding fields of table itab where matnr in material. write:/ ztype_a. loop at itab. write:/ itab-matnr, itab-ersda, itab-ernam. endloop.

***************** Type Group defined DDIC


TYPE-POOL ZTYPE . constants: ZTYPE_a type i value 10. types: begin of ztype_basu,

matnr like mara-matnr, ersda like mara-ersda, ernam like mara-ernam, end of ztype_basu.

You might also like