Skip to content

ABAP Keyword Documentation →  ABAP - Dictionary →  Classic Objects in ABAP Dictionary →  Database Tables →  Dictionary DDL for Defining Database Tables →  DEFINE TABLE 

DEFINE TABLE - field

Other versions: 7.31 | 7.40 | 7.54

Syntax


[component_annos] 
[foreign_key_annos]
[KEY] field : {data_element [foreign_key]
                            [value_help]}
              |abap. type[(n)|(n,m)]
              [NOT NULL];

Effect

Defines a single database field in the definition of a database table using the Dictionary DDL statement DEFINE TABLE.

  • In front of the field, annotations component_annos can be used to specify the same optional component properties as in the definition of a structure using DEFINE STRUCTURE.
  • The addition KEY defines the table field as a key field.
  • field indicates the name of the database field.
  • data_element or abap.type is used to define the data type of the table field. The same rules apply as in the definition of a structure component, except that only elementary types can be specified here.
  • The addition value_help can be used to assign a search help to a table field whose data type is defined using a data element. This is only applicable to table fields used for input fields of dynpros or Web Dynpros (which is not recommended) and the same applies as in the definition of a structure component.


Example

Defines the database table DEMO_EXPRESSIONS in the Dictionary DDL of the ABAP Development Tools. The types of all fields are determined directly using built-in data types in ABAP Dictionary.

@EndUserText.label : 'Database Table for Expression Examples'
@AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #ALLOWED
define table demo_expressions {
  key mandt  : mandt not null;
  key id     : char1 not null;
  num1       : abap.int4;
  num2       : abap.int4;
  numlong1   : abap.int8;
  numlong2   : abap.int8;
  dec1       : abap.dec(31,0);
  dec2       : abap.dec(31,10);
  dec3       : abap.dec(10,3);
  fltp1      : abap.fltp;
  fltp2      : abap.fltp;
  decf1      : abap.df34_dec(31,0);
  decf2      : abap.df34_dec(31,0);
  char1      : abap.char(10);
  char2      : abap.char(10);
  numc1      : abap.numc(10);
  numc2      : abap.numc(10);
  string1    : abap.string(0);
  string2    : abap.string(0);
  raw1       : abap.raw(10);
  raw2       : abap.raw(10);
  xstring1   : abap.rawstring(0);
  xstring2   : abap.rawstring(0);
  dats1      : abap.dats;
  dats2      : abap.dats;
  tims1      : abap.tims;
  tims2      : abap.tims;
  timestamp1 : abap.dec(15,0);
  timestamp2 : abap.dec(15,0); }

Continue

DEFINE TABLE - foreign_key_annos

DEFINE TABLE - foreign_key