‎2008 Apr 10 1:23 PM
what is the difference between declaring as 'TYPE' or 'LIKE' DATA OBJECTS .
‎2008 Apr 10 1:26 PM
Hi,
TYPE
You use the TYPE addition in various ABAP statements for defining data types and specifying the types of interface parameters or field symbols. The TYPE addition can have various meanings depending on the syntax and context.
LIKE
You use the LIKE addition, similarly to the TYP E addition , in various ABAP statements for defining data types and specifying the types of interface parameters or field symbols. The addition
LIKE <obj>
can be used in the same ABAP statements as the TYPE addition to refer to any data object <obj> that is already visible at that point in the program. The expression <obj> is either the name of the data object or the expression.
You use LIKE to make the new object or type inherit the technical attributes of an existing data object.
type we can use to refer system defined or user defined data types and data dictionary objects..
like we will use in case of refering data dictionary objects only.
Go through the link.
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm
TYPE - Type is used to tell the system what is the type of data object(variable) you want to create .
LIKE: If there is already a data object declared and you want to declare a similar data object you can just refer to the previous data object using like.
type is generally used for declaring variables, parameters for existing data types in abap
for ex: to declare a inter value and character variable of length 10 is as,
data: i1 type i,
c1(10) type c.
like generally refers to existing data objects in abap.
for ex:
data: matnr like mara-matnr,
vbeln like vbap-vbeln.
creating variables matnr, vbeln from existing fields of tables mara, vbap.
when user creates a user defiend structure for work areas, internal tables we generally use type keyword as
types: begin of itab,
.........
.........
........
end of itab.
data: itab1 type itab occurs 0 with header line
Check this thread.
https://forums.sdn.sap.com/click.jspa?searchID=711746&messageID=2270752
https://forums.sdn.sap.com/click.jspa?searchID=711746&messageID=512214
Hope this helps to solve ur problem....
Regards,
Satish
‎2008 Apr 10 1:26 PM
‎2008 Apr 10 1:26 PM
Hi,
TYPE
You use the TYPE addition in various ABAP statements for defining data types and specifying the types of interface parameters or field symbols. The TYPE addition can have various meanings depending on the syntax and context.
LIKE
You use the LIKE addition, similarly to the TYP E addition , in various ABAP statements for defining data types and specifying the types of interface parameters or field symbols. The addition
LIKE <obj>
can be used in the same ABAP statements as the TYPE addition to refer to any data object <obj> that is already visible at that point in the program. The expression <obj> is either the name of the data object or the expression.
You use LIKE to make the new object or type inherit the technical attributes of an existing data object.
type we can use to refer system defined or user defined data types and data dictionary objects..
like we will use in case of refering data dictionary objects only.
Go through the link.
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm
TYPE - Type is used to tell the system what is the type of data object(variable) you want to create .
LIKE: If there is already a data object declared and you want to declare a similar data object you can just refer to the previous data object using like.
type is generally used for declaring variables, parameters for existing data types in abap
for ex: to declare a inter value and character variable of length 10 is as,
data: i1 type i,
c1(10) type c.
like generally refers to existing data objects in abap.
for ex:
data: matnr like mara-matnr,
vbeln like vbap-vbeln.
creating variables matnr, vbeln from existing fields of tables mara, vbap.
when user creates a user defiend structure for work areas, internal tables we generally use type keyword as
types: begin of itab,
.........
.........
........
end of itab.
data: itab1 type itab occurs 0 with header line
Check this thread.
https://forums.sdn.sap.com/click.jspa?searchID=711746&messageID=2270752
https://forums.sdn.sap.com/click.jspa?searchID=711746&messageID=512214
Hope this helps to solve ur problem....
Regards,
Satish
‎2008 Apr 10 1:33 PM
Hi,
The basic difference between TYPE and LIKE
When you want to create a data object referring to a data type then you use TYPE
When you want to create a data object referring to an already existing data object then you use LIKE
You can use TYPE to refer pre defined data types like c, n, dats etc. Type will improve performance.
LIKE is used to refer to an item which is already declared(in the simplest way we can say).
<REMOVED BY MODERATOR>
Thanks.
Edited by: Alvaro Tejada Galindo on Apr 10, 2008 5:59 PM
‎2008 Apr 10 1:42 PM
Hi,
The difference is described very clearly in the thread
https://forums.sdn.sap.com/click.jspa?searchID=10603532&messageID=4219330
<REMOVED BY MODERATOR>
Regards,
Soumya.
Edited by: Alvaro Tejada Galindo on Apr 10, 2008 6:00 PM