Creating Internal Types in Classes 

Prerequisites

For up to date information about data types, classification, visibility, refer to the data types section of the ABAP User’s Guide.

You must not create public data types within global classes.

 

Procedure

  1. Start the Class Editor in change mode.
  2. Choose Types.
  3. To create an internal type within a class, enter the following information:

    - Type
    A unique name to identify the type. The recommended naming convention for internal types in classes is to use the prefix TY_.

    - Visibility
    Defines the visibility. If you make the type private, it can only be accessed from within the class itself. If the type is protected, it is also visible to the subclasses of the class.

    - Modeled
    If you select this option, the system does not enter the type in the class pool. You will not be able to address the component at runtime.

    - Typing method
    ABAP keyword indicating the reference type. This can be one of TYPE, LIKE, or TYPE REF TO (for class references).

    - Reference type
    You can use any elementary ABAP type (including generic types) or object type (classes and interfaces).

    - Description
    Short description of the type.
  4. Repeat steps 1-3 for any further types.
  5. Save your entries.
  6. If you need to qualify an internal data type in a class further (for example, to specify the field length of a character field), choose Direct type entry. Note that this only makes sense if you have not selected Only modeled.


    The contents of the class pool appear for the corresponding visibility section.
  7. Modify the data type

  8. Check the syntax.
  9. Save your entries.
  10. Choose Back to return to the Internal types display.

Result

You have not created internal data types within your class. You can use these in your class, and, if they are defined as protected, also in its subclasses. You can define private and protected attributes and interface parameters using the TYPE addition.