Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

type and like

Former Member
0 Likes
1,098

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,073

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.

8 REPLIES 8
Read only

Former Member
0 Likes
1,073

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.

Read only

Former Member
0 Likes
1,073

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

Read only

Former Member
0 Likes
1,073

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

Read only

Former Member
0 Likes
1,073

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.

Read only

Former Member
0 Likes
1,073

TYPE : it will allocate memory during execution (object type).

LIKE : it will allocate memory immediately

Type will improve performance.

Read only

Former Member
0 Likes
1,074

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.

Read only

Former Member
0 Likes
1,073

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

Read only

Former Member
0 Likes
1,073

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