Show TOC

Creating Components from ScratchLocate this document in the navigation structure

Definition

A component always consists of a name and its type information, which can be followed optionally by a foreign key or a value help assignment.

Notes

You can use the optional keywords REFERENCE TO for defining reference-like components directly in the structure. Data references can be defined by a reference to any data type in ABAP Dictionary or to the generic type DATA. Object references can be defined by a reference to classes or interfaces in the class library or to the generic type OBJECT.

You can use the optional keyword KEY in front of a component definition to define it as a key field of the structure. This is relevant for structures that are bound into database tables. Also, components of structures used as lock parameters in a lock object must be defined as KEY fields.

You can use the optional NOT NULL keywords at the end of a component definition to define that the field needs to have initial values and cannot be null in a database table. Therefore this is relevant for structures that are bound into database tables only.

Example

The employee structure defines the following components:

  • name is typed with the employee_name data element
  • date_of_birth is typed to the predefined dictionary type abap.dats in order to contain a date value
  • address is defined as a reference to the if_address_object interface
DEFINE TYPE employee {
  name          : employee_name;
  date_of_birth : abap.dats;
  address       : REFERENCE TO if_address_object;
...
}