Application Development 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: 

wat is the difference between Data and types

Former Member
0 Kudos

Wat is the diff between DATA and TYPES

EX:

<b>Data</b> A type I

<b>Types</b> A type I

And In which case do we use the Above mentioned Data types.

Message was edited by:

Ravi Kumar B

1 ACCEPTED SOLUTION
8 REPLIES 8

Former Member
0 Kudos

Hi

when u declare like

Data A type I

then u can use variable A directly and populate it with any integer.

But when u use

Types A type I

then u need to declare a variable of that type n then only u can use it in program

Former Member
0 Kudos

The statement DATA declares a variable of any data type. The declared data object is visible within the current context as of this position. Within the declaration part of a class or an interface, DATA declares an instance attribute whose validity is bound to an instance of a class

The syntax of the DATA statement corresponds to the syntax of the TYPES statement, with the exception of two additions. In this way, a new data type can be defined during the declaration of a data object. The most important difference compared with the statement TYPES is that a data type defined using DATA - not derived from an existing type - is available only as a property of the declared data object and is not independent. This kind of data type is bound to its data object.

Data objects that are declared in a program, but are not accessed there statically, cause a warning message in the enhanced program check.

The TYPES statement defines either an independent data type dtype or a structured data type struc_type. The naming conventions apply to the names dtype and struc_type. The defined data type can be viewed within the current context from this position.

Former Member
0 Kudos

The data statement will allocate some memory to the variable and can store a value.

Type is only a structure definition. Using a type you can declare data.

TYPE : abc type i.

DATA: def type abc.

This will work just like

DATA: def type i.

ashish_gupta11
Explorer
0 Kudos

Hi Ravi,

As you know abap is based on oops concept .so with data statement this create a data object for program which give help to call anything in program.

and types define the data type which is local for program.

thanks ,

Ashish

Former Member
0 Kudos

Hi,

->User-defined elementary data types are based entirely on predefined elementary data types.

->To define your own elementary data types, you use the TYPES statement.

<b>

reward points if useful.</b>

regards,

Vinod Samuel.

Former Member
0 Kudos

Hi ravi,

Types is actually used to create a user-defined type of data type and Type is used to refer existing data type.

Data Declarations is used to refer a variable or constant using a data type.

Example1:

DATA: v_num type i.

DATA: v_date type sy-datum.

DATA: v_pernr like pa0000-pernr.

Example2:

Types: A type i.

DATA: v_num2 type A.

means that v_num2 is of type i.

Former Member
0 Kudos

Hi ravi,

DATA a type i. means u r creating one object. which is of type integer.

for object (a) internally 4 bytes memory allocates..

OBJECTS always declared with data keyword.

TYPES a type i. means u r creating an datatype (a) of type integer.

now (a) also acts like a integer. memory does not allocate for (a).

here both are same : data b type a EQUAL TO data b type i.

Thanks and regards,

Surya