Wednesday, February 1, 2012

ABAP tye pools

TYPE-POOL HKTST.
TYPES: BEGIN OF HKTST_TYP1,
COL1(10),
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, as shown in the following program:
PROGRAM SAPMZTST.
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 DATA statement and the value of the constant is, as the output shows, known in the program.

Any ABAP program can use this definition with the TYPE-POOLS statement, as shown in the following program:
PROGRAM SAPMZTST.
TYPE-POOLS HKTST.
DATA: DAT1 TYPE HKTST_TYP1,
DAT2 TYPE HKTST_TYP2 VALUE '1.23'.
WRITE: DAT2, / HKTST_ELEVEN.
The output is: