Register Login

Difference between TYPE and LIKE in ABAP Programming

Updated May 18, 2018

Type vs Like in ABAP

In ABAP programming we define own data types using the statement.

TYPES dtype [TYPE type|LIKE dobj] ...

and declare its own variables or instance attributes of classes using the statement

DATA var [{TYPE type}|{LIKE dobj}] ...

TYPE: allows you to construct new data types. The new data types are linked to the database objects and can be referenced them using LIKE.

You can use LIKE to refer to any object that has been declared using DATA or a similar statement, and is visible in the current context.  The data object only has to have been declared. It is irrelevant whether the data object already exists in memory when you make the LIKE reference.
Thus with TYPE, you assign data type directly to the data object while declaring and with LIKE, you assign the data type of another object to the declaring data object. The data type is referenced indirectly.

Type is a keyword used to refer to a data type whereas Like is a keyword used to copy the existing properties of already existing data object.


×