Understanding type definition
This is an introduction to types.
The
TYPE
instruction declares a user-defined type, which can be based on:
- Primitive data types (
INTEGER
,VARCHAR(n)
) - Records (
RECORD ... END RECORD
,RECORD ... LIKE tabname.*
) - Arrays (
DYNAMIC ARRAY OF ...
) - Dictionaries (
DICTIONARY OF ...
) - Function references (
FUNCTION name(type,...) RETURNS ...
) - Interfaces (
INTERFACE ... END INTERFACE
)
Once declared, a type can be referenced in the declaration of program variables, or in other types.
Types are typically defined to avoid the repetition of complex structured types.
Tip: User-defined types improve code readability by centralizing data structure
definitions. Consider using
PUBLIC TYPE
definitions to share types across modules
with IMPORT FGL
.Types can also be completed with methods to encapsulate the data, and use the concept of polymorphism with interfaces.