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

difference in type declaration

Former Member
0 Likes
710

Hi friends

can any one tell me what exactly is the differnce between the below 2 declrations

a) Types:

Begin of TY_STRUC1,

F1 type I,

F2 type P,

F3(10) type C,

F4(5) type N,

End of TY_STRUC1.

i have declared it using types .

b) data :

Begin of TY_STRUC1,

F1 type I,

F2 type P,

F3(10) type C,

F4(5) type N,

End of TY_STRUC1.

i have declared it using data statement.

can any one tell me technically what exactly is the difference between the above 2 declarations

Regards

Priyanka.

5 REPLIES 5
Read only

Former Member
0 Likes
688

with type you can allocate any data to that.

and next one can act as work area because it is a field string.

cheers

s.janagar

Read only

Former Member
0 Likes
688

Hello Priyanka,

When you declare something like a type, you can reuse it as a declaration type wherever required in your program, whereas the other data declaration, you can just directly use that as a structure..

Say for example, if you want to declare a structure similar to ty_struc1 in a subroutine, then you can declare there as

data : wa_struc type ty_struc1.

whereas if you have the use the other one, you need to use a 'like' statement.

Read only

Former Member
0 Likes
688

Priyanka,

Second one can be directly used as Work Area whereas for the first one you need to create work area again by using Data statement as shown below

Data: wa_struc1 type TY_STRUC1.

Check ABAPDOCU transaction for more examples on this.

Thanks,

Babu Kilari

Read only

Former Member
0 Likes
688

Hello,

When u are declaring using TYPES key word that is user specifed it will not allocate the memory.

If we declare using DATA key word it will take the memory......

Read only

Former Member
0 Likes
688

Hi Priyanka,

The system does not allocate memory when you declare using types. In the first case, you are just defining a template for an internal table. You can actually hold data, only if you create another internal table using "data" statement.

eg: data: wa_struct1 type ty_struc1.

Now you can use wa_struc1 in the program to hold data.

On the other hand, the second type of declaration, reserves memory area and hence can hold data during progtam execution.

Regards,

Shiny