‎2008 Sep 04 4:34 PM
Hi friends,
iam very much confused between the below 2 types of declaration.
can any one make me clear between the below following declations.
*************************************
1)
types:
var1 type mara-matnr.
data :
var2 type var1.
*************************************
2)
types :
var3 like mara-matnr.
data :
var4 type var3.
**************************************
Regards,
Priyanka.
‎2008 Sep 05 6:11 AM
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.
TYPE is used as a reference to basic type (i.e. c,i,n,..) or data dictionary type (i.e. data elelement, structure, table, table type...).
LIKE is using as reference to an existing data type.
TYPE allocates memory during execution.
LIKE allocates memory immediatly.
TYPE centainly improves performance.
Because in the past (I guess until Release 2 of R/3) there was no TYPE allowed, everything was LIKE and for upward compatibility reasons you can still use it.
thanx.
‎2008 Sep 04 4:39 PM
Hi,
In the following two declarations, there is a difference.
1)
types:
var1 type mara-matnr. ( type always refer to the SE11)
I mean the Mara should be created in SE11 tcode.
data :
var2 type var1.
*************************************
2)
types :
var3 like mara-matnr. ( here it is not necessary that it should be an object created in SE11 )
data :
var4 type var3.
for eg:
data: g_matnr type mara-matnr.
types: var3 like g_matnr. - no error
types: var2 type g_matnr. - error will come.
as g_matnr is not declared in Se11.
Regards,
Venkatesh.
‎2008 Sep 04 4:44 PM
Hi,
TYPE will only get the technical specification related to the data element (like data type and data length)
LIKE decalaration will get all the detailsa including semantic and technical detals related to the field or data element.
It is good Programming practivce to use TYPE instead of LIKE (where ever possible). It is memory efficient.
Thanks,
Kartavya
‎2008 Sep 04 4:52 PM
Hi Priyanka,
The fundamental differance between the type and like is
One is used as data type ( TYPE) the other one as
data object ( DATA )
Data type will not hold memory where as the data object will occupy the memory.
Best practise is to define the data type and use the data object when exactly required
Hope you understand
Regards
Pavan
‎2008 Sep 04 5:15 PM
Type - Reference to a Data type / SE11 Field-Fieldname.
Like - Obselete statement its like saying i want just like this , so inherit all the property of that variable.
‎2008 Sep 04 11:53 PM
TYPE : it will allocate memory during execution (object type).
LIKE : it will allocate memory immediately
Type will improve performance.
‎2008 Sep 05 6:11 AM
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.
TYPE is used as a reference to basic type (i.e. c,i,n,..) or data dictionary type (i.e. data elelement, structure, table, table type...).
LIKE is using as reference to an existing data type.
TYPE allocates memory during execution.
LIKE allocates memory immediatly.
TYPE centainly improves performance.
Because in the past (I guess until Release 2 of R/3) there was no TYPE allowed, everything was LIKE and for upward compatibility reasons you can still use it.
thanx.
‎2008 Sep 05 6:14 AM
hi,
" type " refers to a table data type or table data objects you can also use " like" also but it is now obsolete
hope it will help you
regards
rahul sharma
‎2008 Sep 05 6:19 AM
Hi,
Type is basically used to refer to the table data types.
You can define a structure using types.
Moreover,
*TYPE *: allocates memory during execution (object type).
LIKE : allocates memory immediately
Type will improve performance.
The same can be achieved by using like but it has been declared obsolete now.
Please refer to the following link
http://help.sap.com/search/highlightContent.jsp
Regards,
Manish
Edited by: MANISH GUPTA on Sep 5, 2008 7:20 AM
Edited by: MANISH GUPTA on Sep 5, 2008 7:23 AM