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

please tell me the difference between types and data

Former Member
0 Likes
923

please tell me the difference between this two.

TYPES: begin of itab,

matnr type mara-matnr,

mtart type mara-mtart,

end of itab.

DATA : begin of itab,

matnr type mara-matnr,

mtart type mara-mtart,

end of itab.

When to use which one.Which is the best one .

and also please tell me the difference between

matnr like mara-matnr

matnr type mara-matnr.

Thanks for all the replies

please tell me the difference between this two.

TYPES: begin of itab,

matnr type mara-matnr,

mtart type mara-mtart,

end of itab.

DATA : begin of itab,

matnr type mara-matnr,

mtart type mara-mtart,

end of itab.

When to use which one.Which is the best one .

and also please tell me the difference between

matnr like mara-matnr

matnr type mara-matnr.

Thanks for all the replies

3 REPLIES 3
Read only

Former Member
0 Likes
666

Hi Madan,

The first one is a define type which you can use to define the work-area and internal table.

The second is direct defination of workarea.

The first one should be use as it is more recommended and suitable for ABAP OO.

To find the diffeence between TYPE and LIKE just search forum using "TYPE vs LIKE" there are lots of threads for this.

Regards,

Atish

Read only

Former Member
0 Likes
666

There are two types of declaring internal talbe.

1)DATA : begin of itab occurs 0,

matnr type mara-matnr,

mtart type mara-mtart,

end of itab.

But this is obsolte.

2) TYPES: begin of wa,

matnr type mara-matnr,

mtart type mara-mtart,

end of wa.

data:itab type standard table of wa with header line.

The 2nd method is recommended.

Generally use like while referring to the dictionary field.Use type while referring the data type of field.

for example

matnr like mara-matnr

now if you see field matnr in table mara , its data elemnt is matnr.

now comes the use of <b>type</b>.

data:matnr type matnr.

Read only

Clemenss
Active Contributor
0 Likes
666

Hi madan,

TYPES will just give a description of a data object. Something like a blueprint. No variable defined at this time.

You can give description for any kind of complexity. This type definition can be used to declare real variables or to give the type of a parameter used in FORM or METHOD.

It is necessary to have TYPES defined if you want to pass internal tables as USING or CHANGING parameters. If you do not use such a type you can't loop or read the table in the FORM or METHOD.

Regards,

Clemens