TYPES - Defining a Structured Type

Basic form

TYPES: BEGIN OF structype,
         ...
       END   OF structype.

The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Operational statements not allowed in structure definitions and New naming conventions.

Effect

Defines the structured type structype, where all of the fields defined between " BEGIN OF structype" and "ENDOFstructype" are components of type structype. You can address individual components of the type using the prefix "structype-",

A type name can be up to 30 characters long. The name may only consist of alphanumeric characters and the underscore character. It may not consist entirely of digits. Special characters such as German umlauts are not allowed. As well as these characters, certain special characters are used internall. However, these should not be used in application programs. SPACE is a reserved name, and cannot therefore be used. Furthermore, you should not use a field in a statement if it has the same name as one of the additions of the keyword (for example: PERFORM SUB USING CHANGING.).

Recommendations for Type Names:

  1. Always start the name with a letter.


  2. Use the underscore to separate compound names (for example, NEW_PRODUCT.


Example

Defines a type with two components NAME und AGE:

TYPES: BEGIN OF PERSON,
         NAME(20) TYPE C,
         AGE      TYPE I,
       END   OF PERSON.

Additional help

Local Data Types in Programs