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

diff: DATA and TYPES

Former Member
0 Likes
612

Hi,

what is the difference in creating internal table using DATA stm and TYPES stm?

Thanks and Regards,

Kalai

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
587

Hi..,

When u create itab with DATA ,, the initial memory will be allocated for the internal table ...( Here the object is created )

But when with TYPES no memory will be created !!!( Here the object is not yet created, it just stores the type of the table..thats it )..

again u need to define a table with DATA statement of this TYPE.

Try this simple code..

*************

data w_value type i.

w_value = 2.

*************

types w_value type i.

w_value = 2.

*************

The first case is correct .. because w_value is a variable which has some memory and can store a value !!

But the second case gives an error !!! because w_value doesnot have any memory !!! its type is just created , not the object..

i hope u understood !!

reward all helpful answers,

sai ramesh

6 REPLIES 6
Read only

Former Member
0 Likes
588

Hi..,

When u create itab with DATA ,, the initial memory will be allocated for the internal table ...( Here the object is created )

But when with TYPES no memory will be created !!!( Here the object is not yet created, it just stores the type of the table..thats it )..

again u need to define a table with DATA statement of this TYPE.

Try this simple code..

*************

data w_value type i.

w_value = 2.

*************

types w_value type i.

w_value = 2.

*************

The first case is correct .. because w_value is a variable which has some memory and can store a value !!

But the second case gives an error !!! because w_value doesnot have any memory !!! its type is just created , not the object..

i hope u understood !!

reward all helpful answers,

sai ramesh

Read only

Former Member
0 Likes
587

TYPES is used for declaring the structure of the internal table ,

DATA statement is used for creation of internal table with or without header line

TYPES : BEGIN OF ITAB,

matnr like mara-matnr,

END OF ITAB.

data : itab1 type table of itab with header line.

Read only

Former Member
0 Likes
587

hi,

1.Data statment is used to define variables refeering to already existing data types ..that may be standard data types (c, n, d, t, i,f etc) or user defined types (eg. referring to any data object or complex types) while types statement is used to define user defined data types based on standard data type or may be existing (previously defined types)types.

2. Types doesnt occupy memory and can not hold values whils variable defined using data stmt occupies memory as well as can have values.

same is the case with type and like addition.

like addition expect an ddic object referance while type addition may refer to user defined types.

check this thread

Regards

Sailaja.

Read only

Former Member
0 Likes
587

Hi,

using "types" is for creating the user defined data types using the existing types(c,n,i,p,mara-matnr,lfa1-lifnr,......).

using "data" is for creating the field strings,internal tables(variables).

regards,

bharat.

Read only

Former Member
0 Likes
587

Data : - It is Used to declare varables

Types : Its is used to create our own data types

Read only

hermanoclaro
Participant
0 Likes
587

The answers that people gave explains about the technical details of the declaration mathods. I have nothing to add in this point, only by it's usage. I always use, when it's possible, declarations with types because they come at hand with you need to declare headerlines and tables of the same type and when you are developing something on a ecc6 system or later, when you need to declare a table without headerline because of the amplied verif.

Hope this helps you out.

Regards,