‎2009 Apr 23 5:06 AM
Hi Gurus,
I have a small doubt in basic ABAP.
What is the exact difference between the below statements.
Types: Begin of ty_data,
matnr type mara-matnr,
end of ty_data.
Types: Begin of ty_data,
matnr type matnr,
end of ty_data.
Types: Begin of ty_data,
matnr like mara-matnr,
end of ty_data.
Types: Begin of ty_data,
matnr like matnr,
end of ty_data.
data: matnr type mara-matnr.
data: matnr type matnr
data: matnr like mara-matnr
data: matnr like matnr.
In those above statement which are correct. And the difference between those statements.
Thanks,
Srihari.
‎2009 Apr 23 5:11 AM
Hi,
All these below give you the same thing. IT basically a declaration for a structure type which can be used as type for internal table. However its better to use TYPE instead of LIKE according the latest conventions and also TYPE is acceptable in OO ABAP as against LIKE.
Types: Begin of ty_data,
matnr type mara-matnr,
end of ty_data.
Types: Begin of ty_data,
matnr type matnr,
end of ty_data.
Types: Begin of ty_data,
matnr like mara-matnr,
end of ty_data.
Same is the case for the declaration as given below which declares varaibles of type matnr i.e material number.
data: matnr type mara-matnr.
data: matnr type matnr
data: matnr like mara-matnr
data: matnr like matnr.
Regards,
Mansi.
‎2009 Apr 23 5:47 AM
hi
type refers the existing data type
like refers the existing data object
hope it will help u .
‎2009 Apr 23 6:06 AM
hi,
LIKE means the datatype of the variable is similar to the referenced variable.
TYPE means it is a predefined data type.
Eg:
DATA int TYPE i.
Here int is of integer data type.
DATA var LIKE int.
var IS a variable having same data type of int. which in turn is integer.
You can find these helpful when you reference database table variables... You need not know what is the datatype defined.
Also it adds to FLEXIBILITY.
Whenever you make changes to your database tables and fields,
that change is REFLECTED back to your program that is,
You need not change all your program code when you change your table fields...
Hope you understand and appreciate the flexibility that SAP provides to the programmers...
Thanks
Arun
‎2009 Apr 23 7:22 AM
Hi,
data: matnr type matnr.
Here you define matnr variable type matnr(data type) .
Matnr is a standard data element contains Data Type ' CHAR ' and Length ' 18 ' .
data: matnr like mara-matnr
here you are defining matnr variable which contain all the technical attributes of mara-matnr.
here you are giving data type to matnr w.r.t mara-matnr.
Regards,
Himanshu