Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Declaring Data Objects →  DATA 

DATA - TYPE, LIKE

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


DATA var { {TYPE [LINE OF] type} 
         | {LIKE [LINE OF] dobj} }
         [VALUE  val|{IS INITIAL}]
         [READ-ONLY].

Effect

When a type data type or a dobj data object is specified, the data type of variable var is already fully defined before the declaration. The syntax and meaning of the additions TYPE and LIKE are exactly the same as the definition of the data types with TYPES, except for the following:

  • In the case of DATA, a table type can be specified after TYPE that is generic with respect to its secondary table key (thanks to the addition WITH FURTHER SECONDARY KEYS). This type attribute is not relevant for the declared data object.

If TYPE and LIKE are not specified, a data object with the bound data type c of length 1 is created.


Notes

  • For internal tables, the declaration of the primary table key as a standard key can be critical for various reasons. It is best to define the key fields explicitly instead. In the statement above, therefore, check whether a table with standard key is created by mistake if using a generic standard table type.
  • If an enumerated type is specified after TYPE or a data object with this type is specified after LIKE, an enumerated variable is created.

Example

Uses the TYPE addition to declare a work area for a SELECT statement. Uses the LIKE addition to declare a further data objects of the same type.

DATA wa TYPE scarr. 
SELECT SINGLE * 
       FROM scarr 
       WHERE carrid = 'BA' 
       INTO @wa. 

DATA buffer LIKE wa. 
buffer = wa.